Exemplo n.º 1
0
 public function SendErrorMail()
 {
     $letter .= "<html><head><META http-equiv='Content-type' content='text/html; charset=koi8-r' /></head><body>";
     $letter .= iconv("UTF-8", fvSite::$fvConfig->get("email.encoding"), $this->exTempl->template);
     $letter .= "</body></html>";
     $mime_mail = new html_mime_mail();
     $mime_mail->add_html($letter);
     $mime_mail->build_message("k");
     return $mime_mail->SendMail($this->from_email, iconv("UTF-8", fvSite::$fvConfig->get("email.encoding"), $this->from_name), $this->error_email, iconv("UTF-8", fvSite::$fvConfig->get("email.encoding"), $name), iconv("UTF-8", fvSite::$fvConfig->get("email.encoding"), $this->exTempl->theme), "text/plain");
 }
Exemplo n.º 2
0
function mailIt($htmltosend, $emailto = '', $emailfrom = '', $emailsubj = '', $attachment = '')
{
    global $system;
    include_once 'class.smtp.inc';
    include_once 'class.html.mime.mail.inc';
    include_once 'mimePart.php';
    define('CRLF', "\r\n", TRUE);
    $mail = new html_mime_mail(array('X-Mailer: Html Mime Mail Class'));
    if ($attachment != '') {
        $mail->add_attachment($attachment, 'ordine.csv', 'application/csv');
        //metti un nome e un mime type a piacimento, secondo quel che vuoi
    }
    $mail->add_html($htmltosend, $emailsubj);
    if (!$mail->build_message()) {
        exit('Failed to build email');
    }
    $params = array('host' => '65.125.231.122', 'port' => 25, 'helo' => 'localhost', 'auth' => FALSE, 'user' => '', 'pass' => '');
    $smtp =& smtp::connect($params);
    $send_params = array('from' => $emailfrom, 'recipients' => array($emailto), 'headers' => array('From: ' . $system->SETTINGS['sitename'] . ' <' . $emailfrom . '>', 'To: ' . $emailto . '', 'Subject: ' . $emailsubj));
    $mail->smtp_send($smtp, $send_params);
}
Exemplo n.º 3
0
 function send_messages()
 {
     ignore_user_abort(1);
     set_time_limit(0);
     flush();
     $message = $this->build_message();
     if ($this->type == 'Email-Admin') {
         $sql = "Select distinct u.Email, m.message_ID  from messages_to_contacts m, blast_system_users u  where m.system_user_ID= u.id and  m.status = 'New' and  m.blast_ID =" . $this->blast_ID;
     } else {
         $sql = "Select distinct u.Email, m.message_ID  from messages_to_contacts m, userdata u  where m.user_ID= u.id and  m.status = 'New' and m.blast_ID =" . $this->blast_ID;
     }
     $R = $this->dbcon->Execute($sql) or die($sql . $this->dbcon->ErrorMsg());
     $this->set_message_blast_status('Loaded', 'New');
     $this->set_blast_status("Sending Messages");
     $this->set_start_time();
     $good = 0;
     $bad = 0;
     $total = 0;
     while (!$R->EOF) {
         if (email_is_valid($R->Fields("Email"))) {
             $this->set_message_status($R->Fields("message_ID"), "Sending");
             // cutomize the email message for this user
             $message_output = $this->encode_blast_email($message['htmlmessage'], $message['textmessage'], $R->Fields("message_ID"));
             $mail = new html_mime_mail(array("Reply-To: " . $message['reply_to_address'], "X-Mailer: AMP v3.5", "X-MessageId: " . $R->Fields("message_ID")));
             // cutomize the email message for this user
             if ($message['sendformat'] == 'HTML' or $message['sendformat'] == 'HTML and Text') {
                 $mail->add_html($message_output['html'], $message_output['text']);
             } else {
                 if ($message['sendformat'] == 'Text') {
                     $mail->add_text($message_output['text']);
                 }
             }
             $mail->build_message();
             if ($mail->send("", $R->Fields("Email"), $message['from_name'], $message['from_email'], $message['subject'])) {
                 $good++;
                 $this->set_message_status($R->Fields("message_ID"), "Done");
             } else {
                 $bad++;
                 $this->set_message_status($R->Fields("message_ID"), "Server Failure");
             }
         } else {
             $bad++;
             $this->set_message_status($R->Fields("message_ID"), "Bad Address");
         }
         $total++;
         $R->MoveNext();
     }
     $response = "{$good} messages sent, {$bad} messages failed to send in {$total} attempts.<br>";
     $this->set_blast_status("Complete");
     $this->set_start_time();
     return $response;
 }
Exemplo n.º 4
0
/***************************************
 ** This is optional, it will default to \n
 ** If you're having problems, try changing
 ** this to either \n (unix) or \r (Mac)
 ***************************************/
define('CRLF', "\r\n", TRUE);
/***************************************
 ** Create the mail object. Optional headers
 ** argument. Do not put From: here, this
 ** will be added when $mail->send
 ** Does not have to have trailing \r\n
 ** but if adding multiple headers, must
 ** be seperated by whatever you're using
 ** as line ending (usually either \r\n or \n)
 ***************************************/
$mail = new html_mime_mail('X-Mailer: Html Mime Mail Class');
/***************************************
 ** We will just send a text email
 ***************************************/
$text = $mail->get_file('example.txt');
$mail->set_body($text);
/***************************************
 ** Builds the message.
 ***************************************/
$mail->build_message();
/***************************************
 ** Send the email using smtp method.
 ** This is the preferred method of sending.
 ***************************************/
include 'class.smtp.inc';
$smtp = new smtp_class();
Exemplo n.º 5
0
/***************************************
 ** This is optional, it will default to \n
 ** If you're having problems, try changing
 ** this to either \n (unix) or \r (Mac)
 ***************************************/
define('CRLF', "\r\n", TRUE);
/***************************************
 ** Create the mail object. Optional headers
 ** argument. Do not put From: here, this
 ** will be added when $mail->send
 ** Does not have to have trailing \r\n
 ** but if adding multiple headers, must
 ** be seperated by whatever you're using
 ** as line ending (usually either \r\n or \n)
 ***************************************/
$mail = new html_mime_mail('X-Mailer: Html Mime Mail Class');
/***************************************
 ** Read the image background.gif into
 ** $background
 ***************************************/
$background = $mail->get_file('background.gif');
/***************************************
 ** Read the file test.zip into $attachment.
 ***************************************/
$attachment = $mail->get_file('example.zip');
/***************************************
 ** If sending an html email, then these
 ** two variables specify the text and
 ** html versions of the mail. Don't
 ** have to be named as these are. Just
 ** make sure the names tie in to the
Exemplo n.º 6
0
function sendemail($email, $name, $vars, $page = 0)
{
    global $useSMTP, $smtp_server, $smtp_helo, $smtp_uname, $smtp_pword, $mailer_id;
    global $email_from, $reply_to, $friendly_name, $thisUrl;
    //$emailSubj = sprintf("Can you become a Master in self-control %s?", $vars['firstname']);
    include_once AFGPATH . '/includes/class.html.mime.mail.inc';
    define('CRLF', "\r\n", TRUE);
    $mail = new html_mime_mail(array("X-Mailer: {$mailer_id}"));
    if ($smtp_uname != "" || $smtp_pword != "") {
        $smtpauth = TRUE;
    } else {
        $smtpauth = FALSE;
    }
    if (CODEDEBUG) {
        //file_put_contents(AFGPATH.'/file.log', AFGPATH.'/'.$vars['email'].'.txt'.AFGPATH.'/'.$vars['email'].'.html', FILE_APPEND);
    }
    if (file_exists(AFGPATH . '/' . $vars['email'] . '.txt') && file_exists(AFGPATH . '/' . $vars['email'] . '.html')) {
        $email_body = fread($fp = fopen(AFGPATH . '/' . $vars['email'] . '.txt', 'r'), filesize(AFGPATH . '/' . $vars['email'] . '.txt'));
        fclose($fp);
        $html_email_body = fread($fp = fopen(AFGPATH . '/' . $vars['email'] . '.html', 'r'), filesize(AFGPATH . '/' . $vars['email'] . '.html'));
        fclose($fp);
        foreach ($vars as $key => $val) {
            if (strpos($email_body, '[' . trim($key) . ']')) {
                $email_body = preg_replace("/\\[{$key}\\]/", stripslashes($val), $email_body);
            }
        }
        $email_body = preg_replace('/\\[(\\S.*?)\\]/', '', $email_body);
        if ($html_email_body) {
            foreach ($vars as $key => $val) {
                if (strpos($html_email_body, '[' . trim($key) . ']')) {
                    $html_email_body = preg_replace("/\\[{$key}\\]/", stripslashes($val), $html_email_body);
                }
            }
            $html_email_body = preg_replace('/\\[(\\S.*?)\\]/', '', $html_email_body);
            $mail->add_html($html_email_body, $email_body, AFGPATH . '/emails/');
            //$mail->add_html($html_email_body, $email_body, 'img');
        } else {
            $mail->add_text($email_body);
        }
        $mail->build_message();
        $subject = '';
        if ($vars['email'] == 'emails/email-thankyou') {
            $subject = 'Thank you';
        }
        if ($vars['email'] == 'emails/email-thankyou2') {
            $subject = 'Thank you';
        }
        if ($vars['email'] == 'emails/email-flag') {
            $subject = 'Flagged image';
        }
        $headers = array("From: \"{$friendly_name}\" <{$email_from}>", "To: \"{$name}\" <{$email}>", "Subject: " . $subject, "Reply-To: {$reply_to}");
        if ($useSMTP) {
            include_once AFGPATH . '/includes/class.smtp.inc';
            $params = array('host' => $smtp_server, 'port' => 25, 'helo' => $smtp_helo, 'auth' => $smtpauth, 'user' => $smtp_uname, 'pass' => $smtp_pword);
            //echo '<PRE>'.htmlentities($mail->get_rfc822($name, $email, $friendly_name, $email_from, $email_subj, $headers)).'</PRE>';
            $smtp =& smtp::connect($params);
            $send_params = array('from' => $email_from, 'recipients' => $email, 'headers' => $headers);
            $mail->smtp_send($smtp, $send_params);
        } else {
            $mail->send($name, $email, $friendly_name, $email_from, $emailSubj, $headers);
        }
        /*
        if (CODEDEBUG){	        
        	$content = print_r(htmlentities($mail->get_rfc822($name, $email, $friendly_name, $email_from, $email_subj, $headers)), true);
        	file_put_contents(AFGPATH.'/file.log', $content, FILE_APPEND); 
        }
        */
    }
}
Exemplo n.º 7
0
/***************************************
 ** This is optional, it will default to \n
 ** If you're having problems, try changing
 ** this to either \n (unix) or \r (Mac)
 ***************************************/
define('CRLF', "\r\n", TRUE);
/***************************************
 ** Create the mail object. Optional headers
 ** argument. Do not put From: here, this
 ** will be added when $mail->send
 ** Does not have to have trailing \r\n
 ** but if adding multiple headers, must
 ** be seperated by whatever you're using
 ** as line ending (usually either \r\n or \n)
 ***************************************/
$mail = new html_mime_mail('X-Mailer: Html Mime Mail Class');
/***************************************
 ** Read the file test.zip into $attachment.
 ***************************************/
$attachment = $mail->get_file('example.zip');
/***************************************
 ** Since we're sending a plain text email,
 ** we only need to read in the text file.
 ***************************************/
$text = $mail->get_file('example.txt');
/***************************************
 ** To set the text body of the email, we
 ** are using the set_body() function. This
 ** is an alternative to the add_html() function
 ** which would obviously be inappropriate here.
 ***************************************/
Exemplo n.º 8
0
function sendthanks($email, $name, $vars, $page = 0)
{
    global $thisUrl;
    $emailSubj = "Thank you!";
    include_once JG_PLUGIN_DIR . '/lib/class.html.mime.mail.inc';
    define('CRLF', "\r\n", TRUE);
    $wpjg_generalSettings = get_option('jg_general_settings');
    $mail = new html_mime_mail(array("X-Mailer: " . $wpjg_generalSettings['mailer_id']));
    if ($wpjg_generalSettings['smtp_uname'] != "" || $wpjg_generalSettings['smtp_pword'] != "") {
        $smtpauth = TRUE;
    } else {
        $smtpauth = FALSE;
    }
    $tosend = 'thanks_page';
    if (file_exists(JG_PLUGIN_DIR . '/email/' . $tosend . '.txt') && file_exists(JG_PLUGIN_DIR . '/email/' . $tosend . '.html')) {
        $email_body = fread($fp = fopen(JG_PLUGIN_DIR . '/email/' . $tosend . '.txt', 'r'), filesize(JG_PLUGIN_DIR . '/email/' . $tosend . '.txt'));
        fclose($fp);
        $html_email_body = fread($fp = fopen(JG_PLUGIN_DIR . '/email/' . $tosend . '.html', 'r'), filesize(JG_PLUGIN_DIR . '/email/' . $tosend . '.html'));
        fclose($fp);
        foreach ($vars as $key => $val) {
            if (strpos($email_body, '[' . trim($key) . ']')) {
                $email_body = preg_replace("/\\[{$key}\\]/", $val, $email_body);
            }
        }
        $email_body = preg_replace('/\\[(\\S.*?)\\]/', '', $email_body);
        if ($html_email_body) {
            foreach ($vars as $key => $val) {
                if (strpos($html_email_body, '[' . trim($key) . ']')) {
                    $html_email_body = preg_replace("/\\[{$key}\\]/", $val, $html_email_body);
                }
            }
            $html_email_body = preg_replace('/\\[(\\S.*?)\\]/', '', $html_email_body);
            $mail->add_html($html_email_body, $email_body, JG_PLUGIN_DIR . '/email/');
            //$mail->add_html($html_email_body, $email_body, 'img');
        } else {
            $mail->add_text($email_body);
        }
        $mail->build_message();
        $headers = array('From: "' . $wpjg_generalSettings['friendly_name'] . '" <' . $wpjg_generalSettings['email_from'] . '>', 'To: "' . $name . '" <' . $email . '>', 'Subject: ' . $emailSubj, 'Reply-To: ' . $wpjg_generalSettings['reply_to']);
        if ($wpjg_generalSettings['useSMTP']) {
            include_once JG_PLUGIN_DIR . '/lib/class.smtp.inc';
            $params = array('host' => $wpjg_generalSettings['smtp_server'], 'port' => $wpjg_generalSettings['smtp_port'], 'helo' => $wpjg_generalSettings['smtp_helo'], 'auth' => $smtpauth, 'user' => $wpjg_generalSettings['smtp_uname'], 'pass' => $wpjg_generalSettings['smtp_pword']);
            //echo '<PRE>'.htmlentities($mail->get_rfc822($name, $email, $friendly_name, $email_from, $email_subj, $headers)).'</PRE>';
            $smtp =& smtp::connect($params);
            $send_params = array('from' => $wpjg_generalSettings['email_from'], 'recipients' => $email, 'headers' => $headers);
            $mail->smtp_send($smtp, $send_params);
        } else {
            $mail->send($name, $email, $wpjg_generalSettings['friendly_name'], $wpjg_generalSettings['email_from'], $emailSubj, $headers);
        }
        //file_put_contents( '/var/www/html/test6/PHP_errors.log' ,print_R('thanksemail'. htmlentities($mail->get_rfc822($name, $email, $wpjg_generalSettings['friendly_name'], $wpjg_generalSettings['email_from'], $emailSubj, $headers)), true), FILE_APPEND );
        //echo '<PRE>'.htmlentities($mail->get_rfc822($name, $email, $friendly_name, $email_from, $email_subj, $headers)).'</PRE>';
    }
}
Exemplo n.º 9
0
/***************************************
 ** This is optional, it will default to \n
 ** If you're having problems, try changing
 ** this to either \n (unix) or \r (Mac)
 ***************************************/
define('CRLF', "\r\n", TRUE);
/***************************************
 ** Create the mail object. Optional headers
 ** argument. Do not put From: here, this
 ** will be added when $mail->send
 ** Does not have to have trailing \r\n
 ** but if adding multiple headers, must
 ** be seperated by whatever you're using
 ** as line ending (usually either \r\n or \n)
 ***************************************/
$mail = new html_mime_mail('X-Mailer: Html Mime Mail Class');
/***************************************
 ** Read the image background.gif into
 ** $background
 ***************************************/
$background = $mail->get_file('background.gif');
/***************************************
 ** If sending an html email, then these
 ** two variables specify the text and
 ** html versions of the mail. Don't
 ** have to be named as these are. Just
 ** make sure the names tie in to the
 ** $mail->add_html() call further down.
 ***************************************/
$text = $mail->get_file('example.txt');
$html = $mail->get_file('example.html');
Exemplo n.º 10
0
$text = $mail_1->get_file('example.txt');
$mail_1->set_body($text);
/***************************************
 ** Add the attachment
 ***************************************/
$file = $mail_1->get_file('example.zip');
$mail_1->add_attachment($file, 'example.zip', 'application/zip');
/***************************************
 ** Builds the message.
 ***************************************/
$mail_1->build_message();
/***************************************
 ** Don't send this email, but use the
 ** get_rfc822() method to assign it to a
 ** variable.
 ***************************************/
$mail = $mail_1->get_rfc822('John Doe', '*****@*****.**', 'Some one', '*****@*****.**', 'Test for attached email');
/***************************************
 ** Now start a new mail, and add the first
 ** (which is now built and contained in
 ** $mail) to it.
 ***************************************/
$mail_2 = new html_mime_mail('X-Mailer: Html Mime Mail Class');
$mail_2->set_body('This email has an attached email');
$mail_2->add_attachment($mail, 'Test for attached email', 'message/rfc822');
$mail_2->build_message();
$mail_2->send('Richard Heyes', 'richard@[10.1.1.2]', 'A Nother', '*****@*****.**', 'This email has another email attached');
/***************************************
 ** Debug stuff. Entirely unnecessary.
 ***************************************/
echo '<PRE>' . htmlentities($mail_2->get_rfc822('Richard Heyes', 'richard@[10.1.1.2]', 'A Nother', '*****@*****.**', 'This email has another email attached')) . '</PRE>';