示例#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");
 }
示例#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);
}
示例#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;
 }
 ** 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');
/***************************************
 ** Add the text, html and embedded images.
 ** Each embedded image has to be added
 ** using $mail->add_html_image() BEFORE
 ** calling $mail->add_html(). The name
 ** of the image should match exactly
 ** (case-sensitive) to the name in the html.
 ***************************************/
$mail->add_html_image($background, 'background.gif', 'image/gif');
$mail->add_html($html, $text);
/***************************************
 ** This is used to add an attachment to
 ** the email.
 ***************************************/
$mail->add_attachment($attachment, 'example.zip', 'application/zip');
/***************************************
 ** 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();
示例#5
0
文件: index.php 项目: parsonsc/dofe
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); 
        }
        */
    }
}
示例#6
0
文件: index.php 项目: parsonsc/dofe
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>';
    }
}
$text = $mail->get_file('example.txt');
$html = $mail->get_file('example.html');
/***************************************
 ** Add the text, html and embedded images.
 ** Here we're using the third argument of
 ** add_html(), which is the path to the
 ** directory that holds the images. By
 ** adding this third argument, the class
 ** will try to find all the images in the
 ** html, and auto load them in. not 100%
 ** accurate, and you MUST enclose your
 ** image references in quotes, so src="img.jpg"
 ** and NOT src=img.jpg. Also, where possible,
 ** duplicates will be avoided.
 ***************************************/
$mail->add_html($html, $text, './');
/***************************************
 ** Set character set. Not necessary, unless
 ** of course you need to specify one.
 ***************************************/
$mail->set_charset('iso-8859-1');
/***************************************
 ** Builds the message.
 ***************************************/
$mail->build_message();
/***************************************
 ** Sends the message. $mail->build_message()
 ** is seperate to $mail->send so that the
 ** same email can be sent many times to
 ** differing recipients simply by putting
 ** $mail->send() in a loop.