<?

/* ------------------------------------------------------------------- */
/*

*************************************************
*			UWAGA! SKRYPT NIE JEST DARMOWY.			*
*		DALSZE ROZPOWSZECHNIANIE BEZ ZGODY 			*
*			FIRMY ArtGlobal JEST ZABRONIONE.			*
*************************************************

*************************************************
*	WWW.ArtGlobal.PL		PRODUCENT OPROGRAMOWANIA	*
*	NAZWA SKRYPTU:		NIERUCHOMOSCI 6.0			*
*	WERSJA FINALNA:	04.10.2010						*
*	KONTAKT:				kontakt@artglobal.pl			**
*************************************************

Copyright (c) 2010 ArtGlobal. Wszelkie prawa zastrzeżone.

*/
/* ------------------------------------------------------------------- */

class sendMail
{
        function isEmpty ( $string )
        {
                if ( empty( $string ) )
                {
                        return false;
                }
                else
                {
                        return true;
                }
        }
        function mailer ( $do, $userName, $od, $temat, $tresc )
        {
                global $cfg;
                
                require_once('mailer.class.php');
                
                $html .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
                $html .= '<html xmlns="http://www.w3.org/1999/xhtml">';
                $html .= '<meta http-equiv="content-type" content="text/html; charset=iso-8859-2" />';
                $html .= '<style type="text/css">';
                $html .= '* { font-family: Tahoma, sans-serif; color: #5a5a5a; font-size:  11px; }';
                $html .= 'body { background: #ededed; }';
                $html .= 'a { color: #5a5a5a; }';
                $html .= '.fat { background: #ffffff; width: 600px; height: auto; padding: 5px; border: 1px solid #9c9c9c; }';
                $html .= '.main { margin-top: 5px; padding: 5px 2px 5px 2px; border-top: 1px dashed #e8e8e8; }';
                $html .= '.title { font-size: 15px; font-weight: bold; margin-bottom: 10px; }';
                $html .= '.footer { margin-top: 12px; }';
                $html .= '</style>';
                $html .= '<body>';
                $html .= '<table border="0" align="center">';
                $html .= '<tr>';
                $html .= '<td>';
                $html .= '<div class="fat">';
                
                if ( $cfg['mailLogo'] !== '' )
                {
                        $html .= '<a href="' . $cfg['www'] . '" target="_blank"><img src="' . $cfg['mailLogo'] . '" border="0" /></a>';
                }
                
                $html .= '<div class="main">';
                $html .= '<div class=\"title\">Witaj ' . $userName . '!</div>';
                $html .= $tresc;
                $html .= '<div class="footer">' . $cfg['mailFooter'] . '</div>';
                $html .= '</div>';
                $html .= '</div>';
                $html .= '</td>';
                $html .= '</tr>';
                $html .= '</table>';

                $mail = new PHPMailer();
                $mail -> IsSMTP();
                $mail -> PluginDir = "";
                $mail -> Mailer = "smtp";
                $mail -> Host = $cfg['mailSmtpHost'];
                
                if ( $cfg['smtpAuth'] == 'true' )
                {
                        $mail -> SMTPAuth = true;
                }
                else
                {
                        $mail -> SMTPAuth = false;
                }
                
                $mail -> Port = 25;
                $mail -> Username = $cfg['mailLogin'];
                $mail -> Password = $cfg['mailPass'];
                
                if ( empty( $od ) )
                {
                        $mail -> From = $cfg['mailAdmin'];
                        $mail -> FromName = $cfg['wwwSubStr'];
                }
                else
                {
                        $mail -> From = $od;
                        $mail -> FromName = $od;
                }
                
                $mail -> CharSet = "iso-8859-2";
                $mail -> ContentType = "text/html";
                $mail -> SetLanguage("pl", "");
                $mail -> Subject = $temat;
                $mail -> Body = $html;

                $mail -> AddAddress("".$do."");

                if( $mail -> Send() )
                {
                        return true;
                }
                else
                {
                        return false;
                        echo 'error!';
                }

                $mail -> ClearAddresses();
                $mail -> ClearAttachments();
        }
}
?>
