function sendEmail($destinatario, $mittente, $obj, $msg)
{
    $sended = false;
    $mailer = new PHPMailer(true);
    $mailer->IsSMTP();
    $mailer->SMTPAuth = true;
    $mailer->Host = HOST;
    // Server SMTP
    $mailer->Port = PORT;
    // Porta SMTP
    $mailer->Username = USER;
    // SMTP account username
    $mailer->Password = PASS;
    // SMTP account password
    try {
        $mailer->AddAddress($destinatario, "<{$destinatario}>");
        $mailer->SetFrom($mittente, "Ceramiche Sofia - <{$mittente}>");
        $mailer->Subject = $obj;
        $mailer->MsgHTML($msg);
        $sended = $mailer->Send();
    } catch (phpmailerException $e) {
        $e->errorMessage();
    } catch (Exception $e) {
        $e->getMessage();
    }
    //Logout SMTP
    $mailer->SmtpClose();
    unset($mailer);
    return $sended;
}
Exemple #2
0
 public static function sendMail($paramEmailDestinatario, $paramNomeDestinatario, $paramOggetto, $paramTestoMail)
 {
     // Setto i parametri
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->Host = "smtp.gmail.com";
     $mail->SMTPSecure = "ssl";
     $mail->Port = 465;
     $mail->SMTPAuth = true;
     $mail->Username = "******";
     $mail->Password = '******';
     // intestazione
     $mail->From = '*****@*****.**';
     $mail->AddAddress($paramEmailDestinatario);
     $mail->AddReplyTo('*****@*****.**');
     $mail->Subject = $paramOggetto;
     $mail->Body = $paramTestoMail;
     // gestisco l'invio
     if (!$mail->Send()) {
         echo $mail->ErrorInfo;
     } else {
         echo 'email inviati correttamente';
     }
     // chiudo la connessione
     $mail->SmtpClose();
     unset($mail);
 }
 /**
  * Short description of method send
  *
  * @access public
  * @author Bertrand Chevrier, <*****@*****.**>
  * @return int
  */
 public function send()
 {
     $returnValue = (int) 0;
     foreach ($this->messages as $message) {
         if ($message instanceof tao_helpers_transfert_Message) {
             $this->mailer->SetFrom($message->getFrom());
             $this->mailer->AddReplyTo($message->getFrom());
             $this->mailer->Subject = $message->getTitle();
             $this->mailer->AltBody = strip_tags(preg_replace("/<br.*>/i", "\n", $message->getBody()));
             $this->mailer->MsgHTML($message->getBody());
             $this->mailer->AddAddress($message->getTo());
             try {
                 if ($this->mailer->Send()) {
                     $message->setStatus(tao_helpers_transfert_Message::STATUS_SENT);
                     $returnValue++;
                 }
                 if ($this->mailer->IsError()) {
                     if (DEBUG_MODE) {
                         echo $this->mailer->ErrorInfo . "<br>";
                     }
                     $message->setStatus(tao_helpers_transfert_Message::STATUS_ERROR);
                 }
             } catch (phpmailerException $pe) {
                 if (DEBUG_MODE) {
                     print $pe;
                 }
             }
         }
         $this->mailer->ClearReplyTos();
         $this->mailer->ClearAllRecipients();
     }
     $this->mailer->SmtpClose();
     return (int) $returnValue;
 }
Exemple #4
0
function sendgmail($addr, $body)
{
    $config = parse_ini_file('../../catchit/email_config.ini');
    require_once "phpmailer/class.phpmailer.php";
    include "phpmailer/class.smtp.php";
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = "tls";
    $mail->Host = "smtp.gmail.com";
    $mail->Port = 587;
    $mail->Username = $config['address'];
    $mail->Password = $config['password'];
    $mail->Priority = 3;
    $mail->CharSet = 'UTF-8';
    $mail->Encoding = '8bit';
    $mail->Subject = 'Data from Catchit';
    $mail->ContentType = 'text/html; charset=utf-8\\r\\n';
    $mail->From = $config['address'];
    $mail->FromName = 'Catchit';
    $mail->WordWrap = 900;
    $mail->AddAddress($addr);
    $mail->isHTML(FALSE);
    $mail->Body = $body;
    $mail->Send();
    $mail->SmtpClose();
    if ($mail->IsError()) {
        return 'failed to send';
    } else {
        return 'Email has been sent';
    }
}
Exemple #5
0
function sendMail()
{
    $cfg = new ini();
    $cfg->setFileName('./include/config/account.ini');
    $cfg->load();
    $user_mail = $cfg->getElementByValue('user', 'email');
    $mail = new PHPMailer();
    $mail->IsSMTP();
    //$mail->SMTPDebug= 2;
    //konfiguracja serwera
    $mail->PluginDir = "phpmailer/";
    $mail->Mailer = "smtp";
    $mail->Host = $cfg->getElementByValue('server-config', 'Host');
    $mail->SMTPSecure = $cfg->getElementByValue('server-config', 'SMTPSecure');
    $mail->Port = $cfg->getElementByValue('server-config', 'Port');
    //
    $mail->SMTPKeepAlive = true;
    $mail->SMTPAuth = true;
    $mail->Username = $cfg->getElementByValue('server-config', 'Login');
    $mail->Password = $cfg->getElementByValue('server-config', 'Passwort');
    //koniec połączenia
    //baza danych
    $mydb = new DB();
    $qwery = "SELECT `id`, `email` FROM mail_data Where sended=" . $checkbox_value;
    $request = mysql_query($qwery);
    if ($request === false) {
        die('Nie można było odebrać danych do bazy' . ' z powodu blendu:' . mysql_error());
    }
    if (mysql_num_rows() == 0) {
        echo 'Brak danych w bazie';
        exit(1);
    }
    while ($row = mysql_fetch_assoc($request)) {
        $id = $row['id'];
        $address = $row['email'];
        $mail->SetLanguage("pl", "phpmailer/language/");
        $mail->CharSet = "UTF-8";
        $mail->ContentType = "text/html";
        $mail->isHTML(true);
        $mail->From = user_mail;
        $mail->FromName = "Kamil z webbooster";
        $mail->Subject = "Tytuł wiadomości";
        $mail->Body = '
To jest nowa testowa treść, z prawidłowo interpretowanymi polskimi znaczkami, a to jest <b>pogrubione</b>, a to jest <a href="http://www.example.com">link</a><br/>
<div>trolololo</div>
';
        $mail->AddAddress($address);
        if ($mail->Send()) {
            return true;
        } else {
            throw new Exception('"E-mail nie mógł zostać wysłany, przyczyna :".$mail->ErrorInfo', 5);
        }
    }
    //
    $mail->SmtpClose();
    //zamykamy połączeie
}
Exemple #6
0
 /**
  * Test keepalive (sending multiple messages in a single connection)
  */
 function test_SmtpKeepAlive()
 {
     $this->Mail->Body = "This was done using the SMTP keep-alive.";
     $this->BuildBody();
     $subject = $this->Mail->Subject;
     $this->Mail->SMTPKeepAlive = true;
     $this->Mail->Subject = $subject . ": SMTP keep-alive 1";
     $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
     $this->Mail->Subject = $subject . ": SMTP keep-alive 2";
     $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
     $this->Mail->SmtpClose();
 }
Exemple #7
0
 public static function send($para_correo, $para_nombre, $asunto, $cuerpo, $de_correo = null, $de_nombre = null)
 {
     $mail = new PHPMailer();
     $mail->charSet = "UTF-8";
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     $mail->SMTPSecure = 'ssl';
     $mail->Host = Config::get('config.correo.host');
     $mail->Port = Config::get('config.correo.port');
     $mail->Username = Config::get('config.correo.username');
     $mail->Password = Config::get('config.correo.password');
     if ($de_correo != null && $de_nombre != null) {
         $mail->AddReplyTo($de_correo, $de_nombre);
         $mail->From = $de_correo;
         $mail->FromName = $de_nombre;
     } else {
         $mail->AddReplyTo(Config::get('config.correo.from_mail'), Config::get('config.correo.from_name'));
         $mail->From = Config::get('config.correo.from_mail');
         $mail->FromName = Config::get('config.correo.from_name');
     }
     $asunto = "=?utf-8?b?" . base64_encode($asunto) . "?=";
     $mail->Subject = $asunto;
     $mail->Body = $cuerpo;
     $mail->WordWrap = 50;
     $mail->MsgHTML($cuerpo);
     $emails = explode(';', $para_correo);
     if (count($emails) > 1) {
         foreach ($emails as $key => $value) {
             $mail->AddAddress(trim($value), trim($value));
         }
     } else {
         $mail->AddAddress(trim($para_correo), trim($para_correo));
     }
     $mail->AddAddress(Config::get('config.correo.from_mail'), Config::get('config.correo.from_name'));
     $mail->IsHTML(true);
     //Enviamos el correo
     $exito = $mail->Send();
     $intentos = 2;
     //esto se realizara siempre y cuando la variable $exito contenga como valor false
     while (!$exito && $intentos < 1) {
         sleep(2);
         $exito = $mail->Send();
         $intentos = $intentos + 1;
     }
     $mail->SmtpClose();
     return $exito;
 }
function SendMail($ToEmail, $subject, $MessageHTML)
{
    require_once 'class.phpmailer.php';
    // Add the path as appropriate
    $Mail = new PHPMailer();
    $Mail->IsSMTP();
    // Use SMTP
    $Mail->Host = "smtp.gmail.com";
    // Sets SMTP server
    $Mail->SMTPDebug = 2;
    // 2 to enable SMTP debug information
    $Mail->SMTPAuth = TRUE;
    // enable SMTP authentication
    $Mail->SMTPSecure = "tls";
    //Secure conection
    $Mail->Port = 587;
    // set the SMTP port
    $Mail->Username = '******';
    // SMTP account username
    $Mail->Password = '******';
    // SMTP account password
    $Mail->Priority = 1;
    // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
    $Mail->CharSet = 'UTF-8';
    $Mail->Encoding = '8bit';
    $Mail->Subject = $subject;
    $Mail->ContentType = 'text/html; charset=utf-8\\r\\n';
    $Mail->From = '*****@*****.**';
    $Mail->FromName = 'Jitendra Chaudhary';
    $Mail->WordWrap = 900;
    // RFC 2822 Compliant for Max 998 characters per line
    $Mail->AddAddress($ToEmail);
    // To:
    $Mail->isHTML(TRUE);
    $Mail->Body = $MessageHTML;
    //$Mail->AltBody = $MessageTEXT;
    $Mail->Send();
    $Mail->SmtpClose();
    if ($Mail->IsError()) {
        // ADDED - This error checking was missing
        return FALSE;
        echo "check your email address";
    } else {
        return TRUE;
    }
}
function SendMail($ToEmail, $Subject, $MessageHTML, $MessageTEXT)
{
    require ROOT . 'resources/phpmailer/PHPMailerAutoload.php';
    // Add the path as appropriate
    $Mail = new PHPMailer();
    $Mail->IsSMTP();
    // Use SMTP
    $Mail->Host = "smtpauth.bluewin.ch";
    // Sets SMTP server
    $Mail->SMTPDebug = 2;
    // 2 to enable SMTP debug information
    $Mail->SMTPAuth = TRUE;
    // enable SMTP authentication
    //   $Mail->SMTPSecure  = "tls"; // Secure conection
    $Mail->Port = 587;
    // set the SMTP port
    $Mail->Username = '******';
    // SMTP account username
    $Mail->Password = '******';
    // SMTP account password
    $Mail->Priority = 1;
    // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
    $Mail->CharSet = 'UTF-8';
    $Mail->Encoding = '8bit';
    $Mail->Subject = $Subject;
    $Mail->ContentType = 'text/html; charset=utf-8\\r\\n';
    $Mail->From = '*****@*****.**';
    $Mail->FromName = 'The Breakfast Company - XAMPP';
    $Mail->WordWrap = 900;
    // RFC 2822 Compliant for Max 998 characters per line
    $Mail->AddAddress($ToEmail);
    // To:
    $Mail->addCC("*****@*****.**");
    $Mail->isHTML(TRUE);
    $Mail->Body = $MessageHTML;
    $Mail->AltBody = $MessageTEXT;
    $Mail->Send();
    $Mail->SmtpClose();
    if ($Mail->IsError()) {
        // ADDED - This error checking was missing
        return FALSE;
    } else {
        return TRUE;
    }
}
Exemple #10
0
 function send($to, $subject, $content, $sender)
 {
     //echo 'sendmail!!';
     require_once ROOT . DS . 'library' . DS . 'class.phpmailer.php';
     $mail = new PHPMailer();
     $mail->CharSet = "UTF-8";
     $mail->SetLanguage('vi', ROOT . DS . 'library' . '/phpmailer/language/');
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     // enable SMTP authentication
     $mail->SMTPSecure = "ssl";
     // sets the prefix to the servier
     //$mail->Host       = "smtp.gmail.com";      // sets GMAIL as the SMTP server
     //$mail->Port       = 465;                   // set the SMTP port for the GMAIL server
     $mail->Host = $sender['smtp'];
     $mail->Port = $sender['port'];
     $mail->Username = $sender['email'];
     // GMAIL username
     $mail->Password = $sender['password'];
     // GMAIL password
     $from = $sender['email'];
     $mail->AddReplyTo('*****@*****.**', "Jobbid.vn Support");
     $mail->From = $from;
     $mail->FromName = "Jobbid.vn Support";
     $mail->Sender = $from;
     $mail->Subject = $subject;
     //$mail->AltBody    = "Xin chao"; // optional, comment out and test
     //$mail->WordWrap   = 50; // set word wrap
     $mail->MsgHTML($content);
     if (is_array($to)) {
         foreach ($to as $email) {
             $mail->addBCC($email);
         }
     } else {
         $mail->AddAddress($to);
     }
     $mail->IsHTML(true);
     // send as HTML
     if (!$mail->Send()) {
         return false;
     }
     $mail->SmtpClose();
     return true;
 }
function smtpmailer($to, $from, $from_name, $subject, $body)
{
    global $error;
    $username = "******";
    //gautam@searchdrivenlabs.com
    $password = "******";
    //gautam@searchdrivenlabs.com
    $mail = new PHPMailer();
    // create a new object
    $mail->IsSMTP();
    // enable SMTP
    $mail->SMTPDebug = 1;
    // debugging: 1 = errors and messages, 2 = messages only
    $mail->SMTPAuth = true;
    // authentication enabled
    $mail->SMTPSecure = 'ssl';
    // secure transfer enabled REQUIRED for GMail
    $mail->Host = 'rsb21.rhostbh.com';
    $mail->Port = 465;
    $mail->Username = $username;
    $mail->Password = $password;
    $mail->Priority = 1;
    // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
    $mail->CharSet = 'UTF-8';
    $mail->Encoding = '8bit';
    $mail->ContentType = 'text/html; charset=utf-8\\r\\n';
    $mail->SetFrom($from, $from_name);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AddAddress($to);
    $mail->IsHTML(true);
    $mail->WordWrap = 900;
    $mail->SMTPKeepAlive = true;
    if (!$mail->Send()) {
        $error = 'Mail error: ' . $mail->ErrorInfo;
        return false;
    } else {
        $error = 'Message sent!';
        $mail->SmtpClose();
        return true;
    }
}
Exemple #12
0
function email($fromName, $to, $subject, $body)
{
    require_once 'class.phpmailer.php';
    $Mail = new PHPMailer();
    $Mail->IsSMTP();
    $Mail->Host = "hostname.com";
    //SMTP server
    $Mail->SMTPDebug = 0;
    $Mail->SMTPAuth = TRUE;
    $Mail->SMTPSecure = "tls";
    $Mail->Port = 587;
    //SMTP port
    $Mail->Username = '******';
    //SMTP account username
    $Mail->Password = '******';
    //SMTP account password
    $Mail->Priority = 1;
    $Mail->CharSet = 'UTF-8';
    $Mail->Encoding = '8bit';
    $Mail->Subject = $subject;
    $Mail->ContentType = 'text/html; charset=utf-8\\r\\n';
    $Mail->From = '*****@*****.**';
    $Mail->FromName = $fromName;
    $Mail->WordWrap = 900;
    $Mail->AddAddress($to);
    $Mail->isHTML(TRUE);
    $Mail->Body = $body;
    $Mail->AltBody = $body;
    $Mail->Send();
    $Mail->SmtpClose();
    if ($Mail->IsError()) {
        return 'emailNotSent';
    } else {
        return 'emailSent';
    }
}
Exemple #13
0
 public function sendMail($email, $subject, $msg = NULL)
 {
     global $websiteName, $emailAddress;
     //Check to see if we sending a template email.
     $message = '';
     if ($msg == NULL) {
         $msg = $this->contents;
     }
     $message .= $msg;
     $message = wordwrap($message, 70);
     $mail = new PHPMailer();
     $mail->IsSMTP();
     // Use SMTP
     $mail->Host = "mail.criticlash.com";
     // Sets SMTP server
     //$mail->SMTPDebug   = 1; // 2 to enable SMTP debug information
     $mail->SMTPAuth = TRUE;
     // enable SMTP authentication
     //$mail->SMTPSecure  = "tls"; //Secure conection
     $mail->Port = '25';
     // set the SMTP port
     $mail->Username = '******';
     // SMTP account username
     $mail->Password = '******';
     // SMTP account password
     $mail->Priority = 1;
     // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
     $mail->CharSet = 'UTF-8';
     $mail->Encoding = '8bit';
     $mail->Subject = $subject;
     $mail->ContentType = 'text/html; charset=utf-8\\r\\n';
     //$mail->From        = $emailAddress;
     $mail->FromName = $websiteName;
     $mail->AddAddress($email);
     // To:
     $mail->isHTML(TRUE);
     $mail->Body = $message;
     $mail->AltBody = $message;
     if (!$mail->Send()) {
         return false;
     } else {
         return true;
     }
     $mail->SmtpClose();
     //return mail($email,$subject,$message,$header);
 }
function send_mail_through_queue($to, $cc, $bcc, $subject, $body, $file_list)
{
    // copy attachment file in common shared folder accross the machines
    $attach_file = array();
    foreach ($file_list as $file) {
        global $attach_folder;
        $copy_file = copy($file['path'], $attach_folder . $file['file_name']);
        $file_array = array("path" => $attach_folder . $file['file_name'], "file_name" => $file['file_name']);
        array_push($attach_file, $file_array);
    }
    // parameter sending over queue for sending email
    $requestParams = array("to" => $to, "cc" => $cc, "bcc" => $bcc, "subject" => $subject, "body" => $body, "file_list" => $attach_file);
    $msg = json_encode($requestParams);
    global $email_purpose;
    $push_msg_over_queue = push_to_queue($email_purpose, $msg);
    if (!$push_msg_over_queue) {
        require_once "class.phpmailer.php";
        $mail = new PHPMailer();
        foreach ($cc_li as $cc_list) {
            if ($cc_list != "") {
                $mail->AddCC($cc_list);
            }
        }
        foreach ($bcc_li as $bcc_list) {
            if ($bcc_list != "") {
                $mail->AddBCC($bcc_list);
            }
        }
        if (!empty($file_list)) {
            foreach ($file_list as $file_list) {
                $path = $file_list['path'];
                $file_name = $file_list['file_name'];
                $mail->AddAttachment("{$path}", "{$file_name}", "base64", "application/octet-stream");
            }
        }
        $mail->IsHTML(true);
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        global $smtp_host, $smtp_port, $smtpfrom, $smtp_fromname, $smtp_user_name, $smtp_pswd;
        $mail->Host = $smtp_host;
        $mail->Port = $smtp_port;
        $mail->From = $smtpfrom;
        $mail->FromName = $smtp_fromname;
        $mail->Username = $smtp_user_name;
        $mail->Password = $smtp_pswd;
        foreach ($to as $to_list) {
            $mail->AddAddress($to_list);
        }
        $mail->Subject = $subject;
        $mail->Body = $body;
        creteLogs(__FILE__, __LINE__, "email send with");
        $send_email = $mail->Send();
        if ($send_email == TRUE) {
            creteLogs(__FILE__, __LINE__, "mail send");
        }
        $mail->SmtpClose();
    }
}
Exemple #15
0
 /**
  * 发送邮件
  * @param $to  接收邮件的帐号,以逗号分隔
  * @param $subject  邮件标题
  * @param $message  邮件内容
  * @param $host 发件服务器地址
  * @param $username 发件人邮箱用户名
  * @param $password 发件人邮箱密码
  * @param $attachment = false 邮件附件 array('附件路径','附件名称')
  * @return mixed bool 是否发送成功
  */
 public static function sendEmail($to, $subject, $message, $host, $username, $password, $attachment = false)
 {
     set_time_limit(0);
     Yii::import('application.extensions.mailer.PHPMailerAutoload', 1);
     $mail = new PHPMailer();
     $mail->IsSMTP();
     // set mailer to use SMTP
     $mail->Host = $host;
     // 发件服务器地址
     $mail->SMTPAuth = true;
     // turn on SMTP authentication
     $mail->Port = 25;
     // 发件服务器端口
     $mail->Username = $username;
     // 发件人邮箱用户名
     $mail->Password = $password;
     // 发件人邮箱密码
     $mail->From = $username;
     // 发件人邮箱
     $mail->FromName = '百程系统邮件';
     // 发件人姓名
     $toArr = explode(',', $to);
     foreach ($toArr as $toEmail) {
         $mail->AddAddress($toEmail, $toEmail);
         // 收件人邮箱地址
     }
     $mail->IsHTML(true);
     $mail->Subject = $subject;
     // 邮件标题
     $mail->Body = $message;
     // 是否带有附件
     if (!empty($attachment) && is_array($attachment)) {
         $mail->AddAttachment($attachment[0], $attachment[1]);
     }
     $mail->AltBody = "text/html";
     $mail->CharSet = "utf-8";
     //设置字符集编码
     return $mail->Send();
     $mail->SmtpClose();
 }
/**
* send email
* 
* @param mixed $to
* @param mixed $subject
* @param mixed $body
*/
function send_mail($email, $subject, $body)
{
    if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
        require 'libs/PHPMailer-master/PHPMailerAutoload.php';
        $mail = new PHPMailer();
        $mail->isSMTP();
        // Set mailer to use SMTP
        $mail->SMTPDebug = 2;
        //$mail->Debugoutput = 'html';
        $mail->Host = 'smtpcorp.com';
        // Specify main and backup server
        $mail->Port = 2525;
        $mail->SMTPAuth = true;
        // Enable SMTP authentication
        $mail->Username = '******';
        // SMTP username
        $mail->Password = '******';
        // SMTP password
        $mail->SMTPSecure = 'tls';
        //'tls';                            // Enable encryption, 'ssl' also accepted
        $mail->Priority = 1;
        //set from
        //$mail->setFrom('*****@*****.**','MrHoang');
        $mail->From = "*****@*****.**";
        $mail->FromName = "MrHoang";
        $mail->addReplyTo('*****@*****.**', 'MrHoang');
        $mail->addAddress($email);
        // Name is optional
        //$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
        //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
        //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
        $mail->isHTML(true);
        // Set email format to HTML
        $mail->CharSet = "UTF-8";
        $mail->Subject = $subject;
        $mail->Body = $body;
        //$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
        if (!$mail->send()) {
            echo "Mailer Error: " . $mail->ErrorInfo;
            echo 'Lỗi server mail, chúng tôi chưa gửi được mã code cho bạn vào email, liên hệ: 01663.930.250';
            $mail->SmtpClose();
        } else {
            $mail->SmtpClose();
            return true;
        }
    } else {
        return 'invalid_email';
    }
}
Exemple #17
0
 /**
  * 系统邮件发送函数
  * @param string $to    接收邮件者邮箱
  * @param string $name  接收邮件者名称
  * @param string $subject 邮件主题
  * @param string $body    邮件内容
  * @param string $attachment 附件列表
  * @return boolean
  * 
  * @author Vonwey <*****@*****.**>
  * @CreateDate: 2013-12-13 下午2:11:04
  */
 public function thinkSendEmail($to, $name, $subject = '', $body = '', $attachment = null)
 {
     $config = C('THINK_EMAIL');
     vendor('PHPMailer.class#phpmailer');
     //从PHPMailer目录导class.phpmailer.php类文件
     $mail = new PHPMailer();
     //PHPMailer对象
     $mail->CharSet = 'UTF-8';
     //设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
     $mail->IsSMTP();
     // 设定使用SMTP服务
     $mail->SMTPDebug = 0;
     // 关闭SMTP调试功能
     // 1 = errors and messages
     // 2 = messages only
     $mail->SMTPAuth = true;
     // 启用 SMTP 验证功能
     //$mail->SMTPSecure = 'ssl';                 // 使用安全协议
     $mail->Host = $config['SMTP_HOST'];
     // SMTP 服务器
     $mail->Port = $config['SMTP_PORT'];
     // SMTP服务器的端口号
     $mail->Username = $config['SMTP_USER'];
     // SMTP服务器用户名
     $mail->Password = $config['SMTP_PASS'];
     // SMTP服务器密码
     $mail->SetFrom($config['FROM_EMAIL'], $config['FROM_NAME']);
     $replyEmail = $config['REPLY_EMAIL'] ? $config['REPLY_EMAIL'] : $config['FROM_EMAIL'];
     $replyName = $config['REPLY_NAME'] ? $config['REPLY_NAME'] : $config['FROM_NAME'];
     $mail->AddReplyTo($replyEmail, $replyName);
     $mail->Subject = $subject;
     $mail->MsgHTML($body);
     $mail->Encoding = '8bit';
     $mail->ContentType = 'text/html; charset=utf-8\\r\\n';
     $mail->AddAddress($to, $name);
     $mail->isHTML(TRUE);
     if (is_array($attachment)) {
         // 添加附件
         foreach ($attachment as $file) {
             is_file($file) && $mail->AddAttachment($file);
         }
     }
     return $mail->Send() ? true : $mail->ErrorInfo;
     $mail->SmtpClose();
 }
Exemple #18
0
 function jmailsend($from, $fromname, $to, $title, $body, $usename, $usepassword, $smtp, $repto, $repname)
 {
     global $met_fd_port, $met_fd_way;
     $mail = new PHPMailer();
     //$mail->SMTPDebug  = 3;
     $mail->CharSet = "UTF-8";
     // charset
     $mail->Encoding = "base64";
     $mail->Timeout = 15;
     $mail->IsSMTP();
     // telling the class to use SMTP
     //system
     if (stripos($smtp, '.gmail.com') === false) {
         $mail->Port = $met_fd_port;
         $mail->Host = $smtp;
         // SMTP server
         if ($met_fd_way == 'ssl') {
             $mail->SMTPSecure = "ssl";
         } else {
             $mail->SMTPSecure = "";
         }
     } else {
         $mail->Port = 465;
         $mail->Host = $smtp;
         // SMTP server
         $mail->SMTPSecure = "ssl";
         //$mail->Host       = 'ssl://'.$smtp; // SMTP server
     }
     $mail->SMTPAuth = true;
     $mail->Username = $usename;
     // SMTP account username
     $mail->Password = $usepassword;
     // SMTP account password
     $mail->From = $from;
     //send email
     $mail->FromName = $fromname;
     //name of send
     //repet
     if ($repto != "") {
         $name = isset($repname) ? $repname : $repto;
         $mail->AddReplyTo($repto, $name);
     }
     $mail->WordWrap = 50;
     // line
     //title
     $mail->Subject = isset($title) ? $title : '';
     //title
     //$mail->AltBody    = "To view the message, please use an HTML compatible email viewer!"; //
     //body
     $body = eregi_replace("[\\]", '', $body);
     $mail->MsgHTML($body);
     //to
     if ($to) {
         $address = explode("|", $to);
         foreach ($address as $key => $val) {
             $mail->AddAddress($val, "");
         }
     }
     //send attech
     //if(isset($data['attach']))
     //{
     //$attach = explode("|",$data['attach']);
     //foreach($attach AS $key => $val)
     //{
     //$mail->AddAttachment($val,"");             // attech
     //}
     //}
     if (!$mail->Send()) {
         $mail->SmtpClose();
         //return "Mailer Error: " . $mail->ErrorInfo;
         return false;
     } else {
         $mail->SmtpClose();
         //return "Message sent!";
         return true;
     }
 }
Exemple #19
0
				color: blue
				}</style>
			<title></title>
		</head>
		<body>
			<h2>Message contact</h2>
			<p>Sujet : '.$contactSujet.'</p>
			<p>Adresse du contact : '.$contactEmail.'</p>
			<p>'.$message.'</p>

			<p>Mail envoyé avec PHPMailer</p>
		</body>
		</html>';
		//envoi du mail et vérification
		$mail->Send();
		
		//deconnexion serveur SMTP
		$mail->SmtpClose();
		// destruction de l'objet mail
		unset($mail);
		// afficher le formulaire	
 ?>
	
<section id="sectionContact">
<h1>Contact</h1>
	<p>Votre message a bien été envoyé</p>
</section> 
	
<?php $this->stop('main_content') ?>

Exemple #20
0
function phorum_smtp_send_messages($data)
{
    $PHORUM = $GLOBALS["PHORUM"];
    $addresses = $data['addresses'];
    $subject = $data['subject'];
    $message = $data['body'];
    $num_addresses = count($addresses);
    $settings = $PHORUM['smtp_mail'];
    $settings['auth'] = empty($settings['auth']) ? false : true;
    if ($num_addresses > 0) {
        try {
            require_once "./mods/smtp_mail/phpmailer/class.phpmailer.php";
            $mail = new PHPMailer();
            $mail->PluginDir = "./mods/smtp_mail/phpmailer/";
            $mail->CharSet = $PHORUM["DATA"]["CHARSET"];
            $mail->Encoding = $PHORUM["DATA"]["MAILENCODING"];
            $mail->Mailer = "smtp";
            $mail->IsHTML(false);
            $mail->From = $PHORUM['system_email_from_address'];
            $mail->Sender = $PHORUM['system_email_from_address'];
            $mail->FromName = $PHORUM['system_email_from_name'];
            if (!isset($settings['host']) || empty($settings['host'])) {
                $settings['host'] = 'localhost';
            }
            if (!isset($settings['port']) || empty($settings['port'])) {
                $settings['port'] = '25';
            }
            $mail->Host = $settings['host'];
            $mail->Port = $settings['port'];
            // set the connection type
            if ($settings['conn'] == 'ssl') {
                $mail->SMTPSecure = "ssl";
            } elseif ($settings['conn'] == 'tls') {
                $mail->SMTPSecure = "tls";
            }
            // smtp-authentication
            if ($settings['auth'] && !empty($settings['username'])) {
                $mail->SMTPAuth = true;
                $mail->Username = $settings['username'];
                $mail->Password = $settings['password'];
            }
            $mail->Body = $message;
            $mail->Subject = $subject;
            // add the newly created message-id
            // in phpmailer as a public var
            $mail->MessageID = $data['messageid'];
            // add custom headers if defined
            if (!empty($data['custom_headers'])) {
                // custom headers in phpmailer are added one by one
                $custom_headers = explode("\n", $data['custom_headers']);
                foreach ($custom_headers as $cheader) {
                    $mail->AddCustomHeader($cheader);
                }
            }
            // add attachments if provided
            if (isset($data['attachments']) && count($data['attachments'])) {
                /*
                 * Expected input is an array of
                 * 
                 * array(
                 * 'filename'=>'name of the file including extension',
                 * 'filedata'=>'plain (not encoded) content of the file',
                 * 'mimetype'=>'mime type of the file', (optional)
                 * )
                 * 
                 */
                foreach ($data['attachments'] as $att_id => $attachment) {
                    $att_type = !empty($attachment['mimetype']) ? $attachment['mimetype'] : 'application/octet-stream';
                    $mail->AddStringAttachment($attachment['filedata'], $attachment['filename'], 'base64', $att_type);
                    // try to unset it in the original array to save memory
                    unset($data['attachments'][$att_id]);
                }
            }
            if (!empty($settings['bcc']) && $num_addresses > 3) {
                $bcc = 1;
                $mail->AddAddress("undisclosed-recipients:;");
            } else {
                $bcc = 0;
                // lets keep the connection alive - it could be multiple mails
                $mail->SMTPKeepAlive = true;
            }
            foreach ($addresses as $address) {
                if ($bcc) {
                    $mail->addBCC($address);
                } else {
                    $mail->AddAddress($address);
                    if (!$mail->Send()) {
                        $error_msg = "There was an error sending the message.";
                        $detail_msg = "Error returned was: " . $mail->ErrorInfo;
                        if (function_exists('event_logging_writelog')) {
                            event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE));
                        }
                        if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) {
                            echo $error_msg . "\n";
                            echo $detail_msg;
                        }
                    } elseif (!empty($settings['log_successful'])) {
                        if (function_exists('event_logging_writelog')) {
                            event_logging_writelog(array("source" => "smtp_mail", "message" => "Email successfully sent", "details" => "An email has been sent:\nTo:{$address}\nSubject: {$subject}\nBody: {$message}\n", "loglevel" => EVENTLOG_LVL_INFO, "category" => EVENTLOG_CAT_MODULE));
                        }
                    }
                    // Clear all addresses  for next loop
                    $mail->ClearAddresses();
                }
            }
            // bcc needs just one send call
            if ($bcc) {
                if (!$mail->Send()) {
                    $error_msg = "There was an error sending the bcc message.";
                    $detail_msg = "Error returned was: " . $mail->ErrorInfo;
                    if (function_exists('event_logging_writelog')) {
                        event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE));
                    }
                    if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) {
                        echo $error_msg . "\n";
                        echo $detail_msg;
                    }
                } elseif (!empty($settings['log_successful'])) {
                    if (function_exists('event_logging_writelog')) {
                        $address_join = implode(",", $addresses);
                        event_logging_writelog(array("source" => "smtp_mail", "message" => "BCC-Email successfully sent", "details" => "An email (bcc-mode) has been sent:\nBCC:{$address_join}\nSubject: {$subject}\nBody: {$message}\n", "loglevel" => EVENTLOG_LVL_INFO, "category" => EVENTLOG_CAT_MODULE));
                    }
                }
            }
            // we have to close the connection with pipelining
            // which is only used in non-bcc mode
            if (!$bcc) {
                $mail->SmtpClose();
            }
        } catch (Exception $e) {
            $error_msg = "There was a problem communicating with SMTP";
            $detail_msg = "The error returned was: " . $e->getMessage();
            if (function_exists('event_logging_writelog')) {
                event_logging_writelog(array("source" => "smtp_mail", "message" => $error_msg, "details" => $detail_msg, "loglevel" => EVENTLOG_LVL_ERROR, "category" => EVENTLOG_CAT_MODULE));
            }
            if (!isset($settings['show_errors']) || !empty($settings['show_errors'])) {
                echo $error_msg . "\n";
                echo $detail_msg;
            }
            exit;
        }
    }
    unset($message);
    unset($mail);
    // make sure that the internal mail-facility doesn't kick in
    return 0;
}
Exemple #21
0
function mailSMTP($from_name, $from, $to, $cc, $bcc, $subject, $message)
{
    include "class.phpmailer.php";
    $mail = new PHPMailer();
    $mail->IsSMTP();
    // send via SMTP
    $mail->Host = "mail.eps.com.vn";
    // SMTP servers
    $mail->SMTPAuth = true;
    // turn on SMTP authentication
    $mail->Username = '******';
    // SMTP username
    $mail->Password = '******';
    // SMTP password
    $mail->From = $from;
    $mail->FromName = $fromname;
    $mail->ClearAddresses();
    $mail->AddAddress($to);
    if ($cc != '') {
        $mail->AddAddress($cc);
    }
    if ($bcc != '') {
        $mail->AddAddress($bcc);
    }
    $mail->WordWrap = 50;
    // set word wrap
    $mail->IsHTML(true);
    $mail->CharSet = "UTF-8";
    $mail->Subject = $subject;
    $mail->Body = $message;
    $ok = $mail->Send();
    //if($ok) echo 'phpmailer 1233';
    //else echo 'phpmailer 3445';
    $mail->SmtpClose();
    return $ok;
}
Exemple #22
0
 public static function sendContact($de_correo, $de_nombre, $asunto, $cuerpo)
 {
     //Carga las librería PHPMailer
     Load::lib('phpmailer');
     //instancia de PHPMailer
     $mail = new PHPMailer(true);
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     // enable SMTP authentication
     $mail->SMTPSecure = 'ssl';
     // sets the prefix to the servier
     $mail->Host = Config::get('config.correo.host');
     $mail->Port = Config::get('config.correo.port');
     $mail->Username = Config::get('config.correo.username');
     $mail->Password = Config::get('config.correo.password');
     $mail->AddReplyTo($de_correo, $de_nombre);
     $mail->From = $de_correo;
     $mail->FromName = $de_nombre;
     $mail->Subject = $asunto;
     $mail->Body = $cuerpo;
     $mail->WordWrap = 50;
     // set word wrap
     $mail->MsgHTML($cuerpo);
     $mail->AddAddress(Config::get('config.sitio.email'), Config::get('config.sitio.nombre'));
     $mail->IsHTML(true);
     // send as HTML
     $mail->SetLanguage('es');
     //Enviamos el correo
     $exito = $mail->Send();
     $intentos = 2;
     //esto se realizara siempre y cuando la variable $exito contenga como valor false
     while (!$exito && $intentos < 1) {
         sleep(5);
         $exito = $mail->Send();
         $intentos = $intentos + 1;
     }
     $mail->SmtpClose();
     return $exito;
 }
 /**
 		Sends mail via SMTP.
 		
 		@param		$mail_data					Mail data.
 	**/
 public function send_mail($mail_data)
 {
     // backwards compatability
     if (isset($mail_data['bodyhtml'])) {
         $mail_data['body_html'] = $mail_data['bodyhtml'];
     }
     require_once ABSPATH . WPINC . '/class-phpmailer.php';
     $mail = new PHPMailer();
     // Mandatory
     $mail->From = key($mail_data['from']);
     $mail->FromName = reset($mail_data['from']);
     $mail->Subject = $mail_data['subject'];
     // Optional
     // Often used settings...
     if (isset($mail_data['to'])) {
         foreach ($mail_data['to'] as $email => $name) {
             if (is_int($email)) {
                 $email = $name;
             }
             $mail->AddAddress($email, $name);
         }
     }
     if (isset($mail_data['cc'])) {
         foreach ($mail_data['cc'] as $email => $name) {
             if (is_int($email)) {
                 $email = $name;
             }
             $mail->AddCC($email, $name);
         }
     }
     if (isset($mail_data['bcc'])) {
         foreach ($mail_data['bcc'] as $email => $name) {
             if (is_int($email)) {
                 $email = $name;
             }
             $mail->AddBCC($email, $name);
         }
     }
     if (isset($mail_data['body_html'])) {
         $mail->MsgHTML($mail_data['body_html']);
     }
     if (isset($mail_data['body'])) {
         $mail->Body = $mail_data['body'];
     }
     if (isset($mail_data['attachments'])) {
         foreach ($mail_data['attachments'] as $attachment => $filename) {
             $encoding = 'base64';
             $this->mime_type($attachment);
             if (is_numeric($attachment)) {
                 $mail->AddAttachment($filename, '', $encoding, $mime_type);
             } else {
                 $mail->AddAttachment($attachment, $filename, $encoding, $mime_type);
             }
         }
     }
     if (isset($mail_data['reply_to'])) {
         foreach ($mail_data['reply_to'] as $email => $name) {
             if (is_int($email)) {
                 $email = $name;
             }
             $mail->AddReplyTo($email, $name);
         }
     }
     // Seldom used settings...
     if (isset($mail_data['wordwrap'])) {
         $mail->WordWrap = $mail_data[wordwrap];
     }
     if (isset($mail_data['ConfirmReadingTo'])) {
         $mail->ConfirmReadingTo = true;
     }
     if (isset($mail_data['SingleTo'])) {
         $mail->SingleTo = true;
         $mail->SMTPKeepAlive = true;
     }
     if (isset($mail_data['SMTP'])) {
         $mail->IsSMTP();
         $mail->Host = $mail_data['smtpserver'];
         $mail->Port = $mail_data['smtpport'];
     } else {
         $mail->IsMail();
     }
     if (isset($mail_data['charset'])) {
         $mail->CharSet = $mail_data['charset'];
     } else {
         $mail->CharSet = 'UTF-8';
     }
     if (isset($mail_data['content_type'])) {
         $mail->ContentType = $mail_data['content_type'];
     }
     if (isset($mail_data['encoding'])) {
         $mail->Encoding = $mail_data['encoding'];
     }
     // Done setting up.
     if (!$mail->Send()) {
         $returnValue = $mail->ErrorInfo;
     } else {
         $returnValue = true;
     }
     $mail->SmtpClose();
     return $returnValue;
 }
Exemple #24
0
function mailPHPMailer($from_name, $from, $to = NULL, $cc = NULL, $bcc = NULL, $subject, $message)
{
    include 'class.phpmailer.php';
    include 'phpmailer.lang-en.php';
    $mail = new PHPMailer();
    $mail->IsSMTP();
    // send via SMTP
    $mail->Host = "mail.eps.com.vn";
    // SMTP servers
    $mail->SMTPAuth = true;
    // turn on SMTP authentication
    $mail->Username = '******';
    // SMTP username
    $mail->Password = '******';
    // SMTP password
    $mail->From = $from;
    $mail->FromName = $from_name;
    $mail->ClearAddresses();
    if (!empty($to)) {
        if (is_array($to)) {
            foreach ($to as $to_addr) {
                $mail->AddAddress($to_addr);
            }
        } else {
            $mail->AddAddress($to);
        }
    }
    if (!empty($cc)) {
        if (is_array($cc)) {
            foreach ($cc as $cc_addr) {
                $mail->AddCC($cc_addr);
            }
        } else {
            $mail->AddCC($cc);
        }
    }
    if (!empty($bcc)) {
        if (is_array($bcc)) {
            foreach ($bcc as $bcc_addr) {
                $mail->AddCC($bcc_addr);
            }
        } else {
            $mail->AddCC($bcc);
        }
    }
    $mail->WordWrap = 50;
    // set word wrap
    $mail->IsHTML(true);
    $mail->CharSet = "UTF-8";
    $mail->Subject = $subject;
    $mail->Body = $message;
    $ok = $mail->Send();
    $mail->SmtpClose();
    return $ok;
}
Exemple #25
0
 function send_email($eml_recipients, $eml_subject, $eml_body, &$eml_error = '', $eml_from_address = '', $eml_from_name = '', $eml_priority = 3)
 {
     /*
     			RECIPIENTS NOTE:
     	Pass in a single email address...
     		user@domain.com
     	Pass in a comma or semi-colon delimited string of e-mail addresses...
     		user@domain.com,user2@domain2.com,user3@domain3.com
     					user@domain.com;user2@domain2.com;user3@domain3.com
     	Pass in a simple array of email addresses...
     		Array (
     						[0] => user@domain.com
     						[1] => user2@domain2.com
     						[2] => user3@domain3.com
     					)
     	Pass in a multi-dimentional array of addresses (delivery, address, name)...
     		Array (
     						[0] => Array (
     							[delivery] => to
     							[address] => user@domain.com
     							[name] => user 1
     							)
     						[1] => Array (
     							[delivery] => cc
     							[address] => user2@domain2.com
     							[name] => user 2
     							)
     						[2] => Array (
     							[delivery] => bcc
     							[address] => user3@domain3.com
     							[name] => user 3
     							)
     					)
     
     ERROR RESPONSE:
     	Error messages are stored in the variable passed into $eml_error BY REFERENCE
     */
     include_once "resources/phpmailer/class.phpmailer.php";
     include_once "resources/phpmailer/class.smtp.php";
     $regexp = '/^[A-z0-9][\\w.-]*@[A-z0-9][\\w\\-\\.]+\\.[A-z0-9]{2,6}$/';
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->Host = $_SESSION['email']['smtp_host']['var'];
     if ($_SESSION['email']['smtp_port']['var'] != '') {
         $mail->Port = $_SESSION['email']['smtp_port']['var'];
     }
     if ($_SESSION['email']['smtp_auth']['var'] == "true") {
         $mail->SMTPAuth = $_SESSION['email']['smtp_auth']['var'];
     }
     if ($_SESSION['email']['smtp_username']['var']) {
         $mail->Username = $_SESSION['email']['smtp_username']['var'];
         $mail->Password = $_SESSION['email']['smtp_password']['var'];
     }
     if ($_SESSION['email']['smtp_secure']['var'] == "none") {
         $_SESSION['email']['smtp_secure']['var'] = '';
     }
     if ($_SESSION['email']['smtp_secure']['var'] != '') {
         $mail->SMTPSecure = $_SESSION['email']['smtp_secure']['var'];
     }
     $eml_from_address = $eml_from_address != '' ? $eml_from_address : $_SESSION['email']['smtp_from']['var'];
     $eml_from_name = $eml_from_name != '' ? $eml_from_name : $_SESSION['email']['smtp_from_name']['var'];
     $mail->SetFrom($eml_from_address, $eml_from_name);
     $mail->AddReplyTo($eml_from_address, $eml_from_name);
     $mail->Subject = $eml_subject;
     $mail->MsgHTML($eml_body);
     $mail->Priority = $eml_priority;
     $address_found = false;
     if (!is_array($eml_recipients)) {
         // must be a single or delimited recipient address(s)
         $eml_recipients = str_replace(' ', '', $eml_recipients);
         if (substr_count(',', $eml_recipients)) {
             $delim = ',';
         }
         if (substr_count(';', $eml_recipients)) {
             $delim = ';';
         }
         if ($delim) {
             $eml_recipients = explode($delim, $eml_recipients);
         }
         // delimiter found, convert to array of addresses
     }
     if (is_array($eml_recipients)) {
         // check if multiple recipients
         foreach ($eml_recipients as $eml_recipient) {
             if (is_array($eml_recipient)) {
                 // check if each recipient has multiple fields
                 if ($eml_recipient["address"] != '' && preg_match($regexp, $eml_recipient["address"]) == 1) {
                     // check if valid address
                     switch ($eml_recipient["delivery"]) {
                         case "cc":
                             $mail->AddCC($eml_recipient["address"], $eml_recipient["name"] ? $eml_recipient["name"] : $eml_recipient["address"]);
                             break;
                         case "bcc":
                             $mail->AddBCC($eml_recipient["address"], $eml_recipient["name"] ? $eml_recipient["name"] : $eml_recipient["address"]);
                             break;
                         default:
                             $mail->AddAddress($eml_recipient["address"], $eml_recipient["name"] ? $eml_recipient["name"] : $eml_recipient["address"]);
                     }
                     $address_found = true;
                 }
             } else {
                 if ($eml_recipient != '' && preg_match($regexp, $eml_recipient) == 1) {
                     // check if recipient value is simply (only) an address
                     $mail->AddAddress($eml_recipient);
                     $address_found = true;
                 }
             }
         }
         if (!$address_found) {
             $eml_error = "No valid e-mail address provided.";
             return false;
         }
     } else {
         // just a single e-mail address found, not an array of addresses
         if ($eml_recipients != '' && preg_match($regexp, $eml_recipients) == 1) {
             // check if email syntax is valid
             $mail->AddAddress($eml_recipients);
         } else {
             $eml_error = "No valid e-mail address provided.";
             return false;
         }
     }
     if (!$mail->Send()) {
         $eml_error = $mail->ErrorInfo;
         return false;
     } else {
         return true;
     }
     $mail->ClearAddresses();
     $mail->SmtpClose();
     unset($mail);
 }
Exemple #26
0
/**
 * Master email function, use for all emails (public calendar & admin console) except newsletter mailings, wrapper for PHPMailer.
 * @since 2.0.0
 * @version 2.2.0
 * @param string $toName name of email recipient
 * @param string|array $toAddress email address of recipient OR array of recipients array($name => $address)
 * @param string $subj subject line of the email
 * @param string $msg message body/contents of the email
 * @param string $fromName name of email sender
 * @param string $fromAddress email Address of email sender
 * @param array $attach Files to attach to email. (Data String, Filename, MIME Type)
 * @param boolean $debug [optional] true = output PHPMailer() SMTP debug info, false = no output (Default:false)
 * @return void
 */
function reMail($toName, $toAddress, $subj, $msg, $fromName = '', $fromAddress = '', $attach = NULL, $debug = false)
{
    global $hc_cfg, $hc_lang_core, $hc_lang_config;
    if (emailStatus() != 1) {
        return -1;
    }
    emailStop();
    if ($hc_cfg[78] == '' || $hc_cfg[79] == '') {
        exit($hc_lang_core['NoEmail']);
    }
    include_once HCPATH . HCINC . '/phpmailer/class.phpmailer.php';
    $fromName = $fromName == '' ? $hc_cfg[79] : $fromName;
    $fromAddress = $fromAddress == '' ? $hc_cfg[78] : $fromAddress;
    $mail = new PHPMailer();
    $host = gethostbynamel('');
    $mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-Version', $hc_cfg[49]));
    $mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-ID', md5($hc_cfg[19])));
    $mail->AddCustomHeader($mail->HeaderLine('X-Helios_Calendar-IP', $host[0]));
    /*	End Edit Restriction
     */
    $mail->CreateHeader();
    $mail->IsHTML(true);
    $mail->CharSet = defined('CONVERT_CHRSET') && function_exists('mb_convert_encoding') ? CONVERT_CHRSET : $hc_lang_config['CharSet'];
    if ($attach != NULL) {
        $mail->AddStringAttachment("{$attach['0']}", "{$attach['1']}", "base64", "{$attach['2']}");
    }
    if (is_array($toAddress)) {
        $mail->SingleToArray = $toAddress;
        foreach ($toAddress as $name => $address) {
            $mail->AddAddress($address, $name);
        }
    } else {
        $mail->AddAddress($toAddress, $toName);
    }
    if ($hc_cfg[71] == 1) {
        $mail->IsSMTP();
        $mail->SMTPKeepAlive = false;
        $mail->SMTPDebug = $debug;
        $mail->Host = $hc_cfg[72];
        $mail->Port = $hc_cfg[73];
        if ($hc_cfg[77] == 1) {
            $mail->SMTPAuth = true;
            $mail->Username = $hc_cfg[75];
            $mail->Password = base64_decode($hc_cfg[76]);
        }
        if ($hc_cfg[74] == 1) {
            $mail->SMTPSecure = "tls";
        } elseif ($hc_cfg[74] == 2) {
            $mail->SMTPSecure = "ssl";
        }
    } else {
        $mail->IsMail();
    }
    $mail->Sender = $hc_cfg[78];
    $mail->From = $fromAddress;
    $mail->FromName = cOut($fromName);
    $mail->AddReplyTo($fromAddress, $fromName);
    $mail->Subject = $subj;
    $mail->Body = $msg;
    $mail->AltBody = strip_tags(str_replace("<br />", "\n", $msg));
    try {
        $mail->Send();
    } catch (phpmailerException $e) {
        exit($e);
    } catch (Exception $e) {
        exit($e);
    }
    if ($hc_cfg[71] == 1) {
        $mail->SmtpClose();
    }
    emailGo();
}
Exemple #27
0
 function hook_shutdown()
 {
     if ($this->mailer != null) {
         $this->mailer->SmtpClose();
     }
 }
Exemple #28
0
        $Mail->Password = '******';
        // gmail account password
        $Mail->Priority = 1;
        // Highest priority - Email priority (1 = High, 3 = Normal, 5 =   low)
        $Mail->CharSet = 'UTF-8';
        $Mail->Encoding = '8bit';
        $Mail->Subject = 'Password Recovery';
        $Mail->ContentType = 'text/html; charset=utf-8\\r\\n';
        $Mail->From = '*****@*****.**';
        //Your email adress (Gmail overwrites it anyway)
        $Mail->FromName = 'lokesh';
        $Mail->WordWrap = 900;
        // RFC 2822 Compliant for Max 998 characters per line
        $Mail->addAddress($to);
        // To
        $Mail->isHTML(TRUE);
        $Mail->Body = $body;
        $Mail->AltBody = 'This is a recovery mail';
        $_SESSION['user1'] = $row;
        if (!$Mail->send()) {
            echo 'Message could not be sent.';
            echo 'Mailer Error: ' . $Mail->ErrorInfo;
            exit;
        }
        $Mail->SmtpClose();
        echo 'Message has been sent';
    } else {
        echo "<span style='color:#ff0000;'> Not found your email in our database</span>";
    }
    //If the message is sent successfully, display sucess message otherwise display an error message.
}
Exemple #29
0
function SendEmail($sSubject, $sMessage, $attachName, $hasAttach, $sRecipient)
{
    global $sSendType;
    global $sFromEmailAddress;
    global $sFromName;
    global $sLangCode;
    global $sLanguagePath;
    global $sSMTPAuth;
    global $sSMTPUser;
    global $sSMTPPass;
    global $sSMTPHost;
    global $sSERVERNAME;
    global $sUSER;
    global $sPASSWORD;
    global $sDATABASE;
    global $sSQL_ERP;
    global $sSQL_EMP;
    $iUserID = $_SESSION['iUserID'];
    // Retrieve UserID for faster access
    // Store these queries in variables. (called on every loop iteration)
    $sSQLGetEmail = 'SELECT * FROM email_recipient_pending_erp ' . "WHERE erp_usr_id='{$iUserID}' " . 'ORDER BY erp_num_attempt, erp_id LIMIT 1';
    // Just run this one ahead of time to get the message subject and body
    $sSQL = 'SELECT * FROM email_message_pending_emp';
    extract(mysql_fetch_array(RunQuery($sSQL)));
    // Keep track of how long this script has been running.  To avoid server
    // and browser timeouts break out of loop every $sLoopTimeout seconds and
    // redirect back to EmailSend.php with meta refresh until finished.
    $tStartTime = time();
    $mail = new PHPMailer();
    // Set the language for PHPMailer
    $mail->SetLanguage($sLangCode, $sLanguagePath);
    if ($mail->IsError()) {
        echo 'PHPMailer Error with SetLanguage().  Other errors (if any) may not report.<br>';
    }
    $mail->CharSet = 'utf-8';
    $mail->From = $sFromEmailAddress;
    // From email address (User Settings)
    $mail->FromName = $sFromName;
    // From name (User Settings)
    if ($hasAttach) {
        $mail->AddAttachment("tmp_attach/" . $attachName);
    }
    if (strtolower($sSendType) == 'smtp') {
        $mail->IsSMTP();
        // tell the class to use SMTP
        $mail->SMTPKeepAlive = true;
        // keep connection open until last email sent
        $mail->SMTPAuth = $sSMTPAuth;
        // Server requires authentication
        if ($sSMTPAuth) {
            $mail->Username = $sSMTPUser;
            // SMTP username
            $mail->Password = $sSMTPPass;
            // SMTP password
        }
        $delimeter = strpos($sSMTPHost, ':');
        if ($delimeter === FALSE) {
            $sSMTPPort = 25;
            // Default port number
        } else {
            $sSMTPPort = substr($sSMTPHost, $delimeter + 1);
            $sSMTPHost = substr($sSMTPHost, 0, $delimeter);
        }
        if (is_int($sSMTPPort)) {
            $mail->Port = $sSMTPPort;
        } else {
            $mail->Port = 25;
        }
        $mail->Host = $sSMTPHost;
        // SMTP server name
    } else {
        $mail->IsSendmail();
        // tell the class to use Sendmail
    }
    $bContinue = TRUE;
    $sLoopTimeout = 30;
    // Break out of loop if this time is exceeded
    $iMaxAttempts = 3;
    // Error out if an email address fails 3 times
    while ($bContinue) {
        // Three ways to get out of this loop
        // 1.  We're finished sending email
        // 2.  Time exceeds $sLoopTimeout
        // 3.  Something strange happens
        //        (maybe user tries to send from multiple sessions
        //         causing counts and timestamps to 'misbehave' )
        $tTimeStamp = date('Y-m-d H:i:s');
        $mail->Subject = $sSubject;
        $mail->Body = $sMessage;
        if ($sRecipient == 'get_recipients_from_mysql') {
            $rsEmailAddress = RunQuery($sSQLGetEmail);
            // This query has limit one to pick up one recipient
            $aRow = mysql_fetch_array($rsEmailAddress);
            extract($aRow);
            $mail->AddAddress($erp_email_address);
        } else {
            $erp_email_address = $sRecipient;
            $mail->AddAddress($erp_email_address);
            $bContinue = FALSE;
            // Just sending one email
        }
        if (!$mail->Send()) {
            // failed- make a note in the log and the recipient record
            if ($sRecipient == 'get_recipients_from_mysql') {
                $sMsg = "Failed sending to: {$erp_email_address} ";
                $sMsg .= $mail->ErrorInfo;
                echo "{$sMsg}<br>\n";
                AddToEmailLog($sMsg, $iUserID);
                // Increment the number of attempts for this message
                $erp_num_attempt++;
                $sSQL = 'UPDATE email_recipient_pending_erp ' . "SET erp_num_attempt='{$erp_num_attempt}' ," . "    erp_failed_time='{$tTimeStamp}' " . "WHERE erp_id='{$erp_id}'";
                RunQuery($sSQL);
                // Check if we've maxed out retry attempts
                if ($erp_num_attempt < $iMaxAttempts) {
                    echo "Pausing 15 seconds after failure<br>\n";
                    AddToEmailLog('Pausing 15 seconds after failure', $iUserID);
                    sleep(15);
                    // Delay 15 seconds on failure
                    // The mail server may be having a temporary problem
                } else {
                    $_SESSION['sEmailState'] = 'error';
                    $bContinue = FALSE;
                    $sMsg = 'Too many failures. Giving up. You may try to resume later.';
                    AddToEmailLog($sMsg, $iUserID);
                }
            } else {
                $sMsg = "Failed sending to: {$sRecipient} ";
                $sMsg .= $mail->ErrorInfo;
                echo "{$sMsg}<br>\n";
                AddToEmailLog($sMsg, $iUserID);
            }
        } else {
            if ($sRecipient == 'get_recipients_from_mysql') {
                echo "<b>{$erp_email_address}</b> Sent! <br>\n";
                $sMsg = "Email sent to: {$erp_email_address}";
                AddToEmailLog($sMsg, $iUserID);
                // Delete this record from the recipient list
                $sSQL = 'DELETE FROM email_recipient_pending_erp ' . "WHERE erp_email_address='{$erp_email_address}'";
                RunQuery($sSQL);
            } else {
                echo "<b>{$sRecipient}</b> Sent! <br>\n";
                $sMsg = "Email sent to: {$erp_email_address}";
                AddToEmailLog($sMsg, $iUserID);
            }
        }
        $mail->ClearAddresses();
        $mail->ClearBCCs();
        // Are we done?
        extract(mysql_fetch_array(RunQuery($sSQL_ERP)));
        // this query counts remaining recipient records
        if ($sRecipient == 'get_recipients_from_mysql' && $countrecipients == 0) {
            $bContinue = FALSE;
            $_SESSION['sEmailState'] = 'finish';
            AddToEmailLog('Job Finished', $iUserID);
        }
        if (time() - $tStartTime > $sLoopTimeout) {
            // bail out of this loop if we've taken more than $sLoopTimeout seconds.
            // The meta refresh will reload this page so we can pick up where
            // we left off
            $bContinue = FALSE;
        }
    }
    if (strtolower($sSendType) == 'smtp') {
        $mail->SmtpClose();
    }
}
Exemple #30
0
function mailSMTP($from_name, $from, $to, $cc, $bcc, $subject, $message)
{
    include_once "class.phpmailer.php";
    $mail = new PHPMailer();
    //    $mail->IsSMTP();                                    // send via SMTP
    //    $mail->Host     = "server1.hostno1.vn";             // SMTP servers
    //    $mail->SMTPAuth = true;                             // turn on SMTP authentication
    //    $mail->Username = '******';             // SMTP username
    //    $mail->Password = '******';                        // SMTP password
    $mail->IsSMTP();
    // send via SMTP
    // $mail->Host     = "web72.vinahost.vn";    // SMTP servers
    $mail->Host = "mail.eps.com.vn";
    // SMTP servers
    $mail->SMTPAuth = true;
    // turn on SMTP authentication
    // $mail->Username = '******';          // SMTP username
    $mail->Username = '******';
    // SMTP username
    // $mail->Password = '******';      // SMTP password
    $mail->Password = '******';
    // SMTP password
    $mail->From = $from;
    $mail->FromName = $from_name;
    $mail->ClearAddresses();
    if (!empty($to)) {
        if (is_array($to)) {
            foreach ($to as $to_addr) {
                $mail->AddAddress($to_addr);
            }
        } else {
            $mail->AddAddress($to);
        }
    }
    if (!empty($cc)) {
        if (is_array($cc)) {
            foreach ($cc as $cc_addr) {
                $mail->AddCC($cc_addr);
            }
        } else {
            $mail->AddCC($cc);
        }
    }
    if (!empty($bcc)) {
        if (is_array($bcc)) {
            foreach ($bcc as $bcc_addr) {
                $mail->AddCC($bcc_addr);
            }
        } else {
            $mail->AddCC($bcc);
        }
    }
    $mail->WordWrap = 50;
    // set word wrap
    $mail->IsHTML(true);
    $mail->CharSet = "UTF-8";
    $mail->Subject = $subject;
    $mail->Body = $message;
    $mail->Port = 25;
    $ok = $mail->Send();
    //if($ok) echo 'phpmailer ok';
    //else
    //{
    //    echo 'phpmailer fail <br />';
    //    echo $mail->ErrorInfo . '<br />';
    //}
    $mail->SmtpClose();
    return $ok;
}