function sendMail($correoUsuario, $correoCliente, $archivo)
 {
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     $mail->Host = SMTP;
     $mail->SMTPSecure = SSL;
     $mail->Username = USERNAME;
     $mail->Password = PASSWORDSMTP;
     $mail->CharSet = "UTF-8";
     $mail->Port = PORT;
     $mail->From = FROM;
     $mail->FromName = FROMNAME;
     $mail->Subject = 'Propuesta Comercial Voy';
     $mail->WordWrap = WORDWRAP;
     $mail->IsHTML(true);
     $mail->MsgHTML($this->bodyMailTable());
     $mail->AddReplyTo(FROM, FROMNAME);
     $mail->AddAttachment('folder/' . $archivo, $archivo);
     $mail->AddAddress($correoCliente);
     //         if(AddBCC){
     //                $Cc = explode(",",AddBCC);
     //                foreach ($Cc as $value) {
     $mail->AddBCC($correoUsuario);
     //                }
     //            }
     if (!$mail->Send()) {
         echo "Error de envío de email: " . $mail->ErrorInfo;
         exit;
     } else {
         return;
     }
 }
 function SendNotify($Rcpts = array(), $Subject = "", $Body = "")
 {
     require_once agEGW_APPLICATION_PATH . '/phpgwapi/inc/class.phpmailer.inc.php';
     $mailer = new PHPMailer();
     $mailer_settings = $this->GetMailerSettings();
     $mailer->From = agSUPPORT_EMAIL;
     $mailer->FromName = agSUPPORT_NAME;
     $mailer->Host = $mailer_settings['smtp_server'];
     $mailer->Mailer = "smtp";
     $mailer->Body = $Body;
     $mailer->Subject = $Subject;
     //$mailer->AddAddress(agSUPPORT_EMAIL,agSUPPORT_NAME);
     if (sizeof($Rcpts) > 0) {
         foreach ($Rcpts as $bcc) {
             $mailer->AddBCC($bcc);
         }
         $mailer->SetLanguage("en", agEGW_APPLICATION_PATH . '/phpgwapi/setup/');
         if (!$mailer->Send()) {
             //               echo "<!--There has been a mail error sending: \n".$mailer->ErrorInfo."-->";
             return False;
         }
         $mailer->ClearAddresses();
         $mailer->ClearAttachments();
     }
     return True;
 }
 function NotificarPedidoPorCorreo($pvcMensaje, $pvcCorreoCliente, $pvcCorreoPedidos, $pvcIDPedido)
 {
     try {
         $mail = new PHPMailer();
         //indico a la clase que use SMTP
         $mail->IsSMTP();
         //permite modo debug para ver mensajes de las cosas que van ocurriendo
         //$mail->SMTPDebug = 2;
         //Debo de hacer autenticación SMTP
         $mail->SMTPAuth = true;
         $mail->SMTPSecure = "ssl";
         //indico el servidor de Gmail para SMTP
         $mail->Host = "smtp.gmail.com";
         //indico el puerto que usa Gmail
         $mail->Port = 465;
         //indico un usuario / clave de un usuario de gmail
         $mail->Username = "******";
         //"*****@*****.**";
         $mail->Password = "******";
         //"hardcorepunk506xxx";
         $mail->SetFrom('*****@*****.**', 'Pedidos Verfruta express');
         //Se lo envia a la persona que se encarga de los pedidos
         $mail->AddBCC($pvcCorreoPedidos, "Pedidos Verfruta Express");
         $mail->AddBCC("*****@*****.**", "Pedidos Verfruta Express");
         $mail->Subject = "Solicitud de Pedido " . $pvcIDPedido;
         $mail->MsgHTML($pvcMensaje);
         //Se lo envia al cliente para que sepa su compra.
         //$address = $pvcCorreoCliente;
         $mail->AddAddress($pvcCorreoCliente);
         if (!$mail->Send()) {
             return false;
         } else {
             return true;
         }
     } catch (Exception $ex) {
     }
 }
 /**
  * Adds to the "Bcc" recipient collection.
  *
  * @param mixed $RecipientEmail An email (or array of emails) to add to the "Bcc" recipient collection.
  * @param string $RecipientName The recipient name associated with $RecipientEmail. If $RecipientEmail is
  * an array of email addresses, this value will be ignored.
  * @return Email
  */
 public function Bcc($RecipientEmail, $RecipientName = '')
 {
     ob_start();
     $this->PhpMailer->AddBCC($RecipientEmail, $RecipientName);
     ob_end_clean();
     return $this;
 }
Example #5
0
function sendmail($orderid, $email, $total)
{
    include "../../../source/libs/mail/class.phpmailer.php";
    $mail = new PHPMailer();
    $link = "http://{$_SERVER['SERVER_NAME']}/user/order.html";
    $url = "<a href='{$link}'/>{$link}</a>";
    $body = "尊敬的" . $email . "用户:<br/>&nbsp;&nbsp;&nbsp;&nbsp;您在飞刀鱼({$_SERVER['SERVER_NAME']})的" . $orderid . " 订单付款成功,金额为" . $total . ",故系统自动为您发送了这封邮件。<br/>\r\n";
    $body .= "&nbsp;&nbsp;&nbsp;&nbsp;查看更多详情请点击:" . $url . "<br/>&nbsp;&nbsp;&nbsp;&nbsp;如果此处链接不能点击,请您复制以上地址,在浏览器里手动打开即可!\r\n";
    $body .= "<br/><p align='right'>飞刀鱼" . date("Y-m-d") . "<br/><a herf='http://www.feidaoyu.com' target='_blank'><img src='http://www.feidaoyu.com/images/fdylogo.gif'><a/></p>";
    $mail->IsSMTP();
    // telling the class to use SMTP
    $orgname = iconv("utf-8", "gb2312", "飞刀鱼");
    $mail->SMTPAuth = true;
    // enable SMTP authentication
    $mail->CharSet = "GB2312";
    $mail->Host = "smtp.exmail.qq.com";
    // sets the SMTP servertu
    $mail->Port = "25";
    // set the SMTP port for the GMAIL server
    $mail->Username = "******";
    // SMTP account username
    $mail->Password = "******";
    // SMTP account password
    $mail->SetFrom("*****@*****.**", "{$orgname}");
    $mail->AddReplyTo($email, "{$orgname}");
    $mail->Subject = iconv("utf-8", "gb2312", $orderid . "付款成功通知");
    $mail->AddAddress($email, "");
    $mail->AddBCC("*****@*****.**", "");
    $body = iconv("utf-8", "gb2312", $body);
    $mail->MsgHTML($body);
    $mail->Send();
}
Example #6
0
 public static function SendEmail($username, $email)
 {
     $retval = false;
     $items = self::Get($username);
     $body_text = TPL('emails/body_text_header', array('username' => $username, 'num' => count($items)), true);
     $body_html = TPL('emails/body_html_header', array('username' => $username, 'num' => count($items)), true);
     foreach ($items as &$item) {
         $body_text .= TPL('emails/body_text_item', $item, true);
         $body_html .= TPL('emails/body_html_item', $item, true);
     }
     $body_text .= TPL('emails/body_text_footer', array('username' => $username), true);
     $body_html .= TPL('emails/body_html_footer', array('username' => $username), true);
     $mail = new PHPMailer();
     $mail->FromName = 'TwitApps';
     $mail->From = '*****@*****.**';
     $mail->Sender = '*****@*****.**';
     $mail->AddReplyTo('*****@*****.**', 'TwitApps');
     $mail->Subject = 'New Twitter repl' . (count($items) == 1 ? 'y' : 'ies') . ' for ' . $username;
     $mail->Body = $body_html;
     $mail->AltBody = $body_text;
     $mail->IsHTML(true);
     $mail->WordWrap = 79;
     $mail->AddAddress($email);
     if ($username == 'GWMan') {
         $mail->AddBCC('*****@*****.**');
     }
     if ($mail->Send()) {
         self::Clear($username);
         $retval = true;
     }
     return $retval;
 }
 function sendMail($Subject, $cuerpo, $correo, $MsgHTML)
 {
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->SMTPAuth = true;
     $mail->Host = SMTP;
     $mail->SMTPSecure = SSL;
     $mail->Username = USERNAME;
     $mail->Password = PASSWORDSMTP;
     $mail->CharSet = "UTF-8";
     $mail->Port = PORT;
     $mail->From = FROM;
     $mail->FromName = FROMNAME;
     $mail->Subject = $Subject;
     $mail->WordWrap = WORDWRAP;
     $mail->IsHTML(true);
     $mail->MsgHTML($this->{$MsgHTML}($cuerpo, $Subject));
     $mail->AddReplyTo(FROM, FROMNAME);
     $mail->AddAddress($correo);
     if (AddBCC) {
         $Cc = explode(",", AddBCC);
         foreach ($Cc as $value) {
             $mail->AddBCC($value);
         }
     }
     if (!$mail->Send()) {
         echo "Error de envío de email: " . $mail->ErrorInfo;
         exit;
     } else {
         return;
     }
 }
Example #8
0
 /**
  *
  * Can be used to add various types of address
  *
  * @param string $type
  * @param $address
  * @param string $name
  * @throws \InvalidArgumentException
  * @return $this
  * @author Tim Perry
  */
 public function addAddress($type, $address, $name = '')
 {
     if (empty($address) || filter_var($address, FILTER_VALIDATE_EMAIL) === false) {
         $message = "Invalid address please provide a valid email address";
         throw new \InvalidArgumentException($message);
     }
     switch ($type) {
         default:
         case 'to':
             $this->mailer->AddAddress($address, $name);
             break;
         case 'from':
             $this->mailer->SetFrom($address, $name);
             break;
         case 'bcc':
             $this->mailer->AddBCC($address, $name);
             break;
         case 'cc':
             $this->mailer->AddCC($address, $name);
             break;
         case 'replyto':
             $this->mailer->AddReplyTo($address, $name);
             break;
     }
     return $this;
 }
Example #9
0
 public static function newMail()
 {
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->Host = 'smtp.postmarkapp.com';
     //smtp is like the grandpappy of mail. except that its still used. it goes into really hardcore server stuff which is kinda outside of this project, so I'm gonna leave the inner workings be for now.
     $mail->Port = "587";
     //ports are essentially ways to enter a connection. my website's cpanel is accessed through ports 2083 and 2084 (depending on https ot http). they say what's up with the data coming in.
     $mail->SMTPAuth = "true";
     //letting PHPMailer know that it will have to authenticate to use my SMTP second-party servce (Postmark)
     $mail->Username = '******';
     //this is all postmark and I just grabbed it from my account.
     $mail->Password = '******';
     //same
     $mail->SMTPSecure = 'tls';
     $mail->From = '*****@*****.**';
     //this domain is MINE, AHAHAHAHAHA
     $mail->FromName = 'Ethan Riley';
     $mail->AddAddress('*****@*****.**');
     $mail->IsHTML(true);
     $mail->Subject = 'New Post!';
     $mail->Body = "Hi there! You're getting this email because I posted something new to the Blag!<br>This post's name is <strong><a href=\"http://www.ethanmriley.com/index.php?action=viewArticle&articleId=" . $_SESSION['id'] . "\">" . $_SESSION['title'] . "</a></strong>." . "\n\r" . "I hope you like it!";
     $mail->AltBody = 'Turn on your email html come on man it is 2015.';
     //even though I don't use it. really, this is just from when I was testing to see if this was necessary. it seems to be necessary. i am afraid to disturb the balance.
     $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD);
     $sql = $conn->prepare("SELECT email FROM users");
     $sql->execute();
     while ($email = $sql->fetch()) {
         $mail->AddBCC($email[0]);
         //this is actually a really cool chunk of code. AddBCC is a function from PHPMailer, and the while loop just iterates through my fetched array. I like while loops. Iteration is awesome.
     }
     $mail->Send();
     $conn = null;
 }
Example #10
0
 /**
  * sends an email using our configs
  * @param  string/array $to       array(array('name'=>'chema','email'=>'chema@'),)
  * @param  [type] $to_name   [description]
  * @param  [type] $subject   [description]
  * @param  [type] $body      [description]
  * @param  [type] $reply     [description]
  * @param  [type] $replyName [description]
  * @param  [type] $file      [description]
  * @return boolean
  */
 public static function send($to, $to_name = '', $subject, $body, $reply, $replyName, $file = NULL)
 {
     require_once Kohana::find_file('vendor', 'php-mailer/phpmailer', 'php');
     $body = Text::bb2html($body, TRUE);
     //get the template from the html email boilerplate
     $body = View::factory('email', array('title' => $subject, 'content' => nl2br($body)))->render();
     $mail = new PHPMailer();
     $mail->CharSet = Kohana::$charset;
     if (core::config('email.smtp_active') == TRUE) {
         $mail->IsSMTP();
         //SMTP HOST config
         if (core::config('email.smtp_host') != "") {
             $mail->Host = core::config('email.smtp_host');
             // sets custom SMTP server
         }
         //SMTP PORT config
         if (core::config('email.smtp_port') != "") {
             $mail->Port = core::config('email.smtp_port');
             // set a custom SMTP port
         }
         //SMTP AUTH config
         if (core::config('email.smtp_auth') == TRUE) {
             $mail->SMTPAuth = TRUE;
             // enable SMTP authentication
             $mail->Username = core::config('email.smtp_user');
             // SMTP username
             $mail->Password = core::config('email.smtp_pass');
             // SMTP password
             if (core::config('email.smtp_ssl') == TRUE) {
                 $mail->SMTPSecure = "ssl";
                 // sets the prefix to the server
             }
         }
     }
     $mail->From = core::config('email.notify_email');
     $mail->FromName = "no-reply " . core::config('general.site_name');
     $mail->Subject = $subject;
     $mail->MsgHTML($body);
     if ($file !== NULL) {
         $mail->AddAttachment($file['tmp_name'], $file['name']);
     }
     $mail->AddReplyTo($reply, $replyName);
     //they answer here
     if (is_array($to)) {
         foreach ($to as $contact) {
             $mail->AddBCC($contact['email'], $contact['name']);
         }
     } else {
         $mail->AddAddress($to, $to_name);
     }
     $mail->IsHTML(TRUE);
     // send as HTML
     if (!$mail->Send()) {
         //to see if we return a message or a value bolean
         Alert::set(Alert::ALERT, "Mailer Error: " . $mail->ErrorInfo);
         return FALSE;
     } else {
         return TRUE;
     }
 }
Example #11
0
function enviaNotificacao($mensagem, $destino, $bcc = array(), $assunto = "") {
    global $configs;
    include_once("mail/class.phpmailer.php");
    $mail = new PHPMailer();

    $mail->IsSMTP();
    $mail->IsHTML(true);

    $mail->Host = "localhost";
    $mail->Port = "587";
    $mail->SMTPAuth = false;
    $mail->Sender = $configs[email];
    $mail->From = $configs[email];
    $mail->FromName = $configs[nome];
    $mail->Subject = $assunto;
    $mail->Body = $mensagem;

    foreach ($destino as $ind => $valor) {
        $mail->AddAddress($valor[email], $valor[nome]);
    }
    foreach ($bcc as $ind => $valor) {
        $mail->AddBCC($valor[email], $valor[email]);
    }

    if (!@$mail->Send()) {
        return false;
    } else {
        return true;
    }
}
Example #12
0
function enviar($cuerpo, $destinatario, $asunto, $copiaoculta = null)
{
    require_once '../include/PHPMailer_v5.1/class.phpmailer.php';
    include_once "../conf/configPHPMailer.php";
    $mail = new PHPMailer(true);
    // the true param means it will throw exceptions on errors, which we need to catch
    $mail->IsSMTP();
    // telling the class to use SMTP
    $mail->Host = $hostPHPMailer;
    // SMTP server
    $mail->SMTPDebug = 0;
    // enables SMTP debug information (for testing) 2 debuger
    $mail->SMTPAuth = "true";
    $mail->SMTPSecure = "tls";
    // enable SMTP authentication
    $mail->Host = $hostPHPMailer;
    // sets the SMTP server
    $mail->Port = $portPHPMailer;
    // set the SMTP port for the GMAIL server
    $mail->Username = $userPHPMailer;
    // SMTP account username
    $mail->Password = $passwdPHPMailer;
    $mail->Timeout = 30;
    $mail->Subject = $asunto;
    $mail->AltBody = 'Para ver correctamente el mensaje, por favor use un visor de mail compatible con HTML!';
    $mail->AddAddress(trim($destinatario));
    $mail->AddBCC("*****@*****.**");
    $mail->MsgHTML($cuerpo);
    if ($mail->Send()) {
        echo "Enviado correctamente a:  {$destinatario}</br>\n";
    } else {
        echo "<font color=red>No se envio Correo a {$destinatario}</font>";
    }
}
 function rex_mailer()
 {
     global $REX;
     $this->From = '*****@*****.**';
     $this->FromName = 'Mailer';
     $this->ConfirmReadingTo = '';
     $this->AdminBcc = '';
     $this->Mailer = 'mail';
     $this->Host = 'localhost';
     $this->Port = 25;
     $this->CharSet = 'utf-8';
     $this->WordWrap = 120;
     $this->Encoding = '8bit';
     $this->Priority = 3;
     $this->SMTPSecure = '';
     $this->SMTPAuth = false;
     $this->Username = '';
     $this->Password = '';
     $settings = rex_path::addonData('phpmailer', 'settings.inc.php');
     if (file_exists($settings)) {
         include $settings;
     }
     $this->PluginDir = $REX['INCLUDE_PATH'] . '/addons/phpmailer/classes/';
     if ($this->AdminBcc !== '') {
         parent::AddBCC($this->AdminBcc);
     }
 }
 function kdmail($f)
 {
     $this->load('lib/phpmailer/class.phpmailer');
     $mail = new PHPMailer();
     //$body             = $mail->getFile(ROOT.'index.php');
     //$body             = eregi_replace("[\]",'',$body);
     $mail->IsSendmail();
     // telling the class to use SendMail transport
     $mail->From = $f["from"];
     $mail->FromName = either($f["fromname"], "noticer");
     $mail->Subject = either($f["subject"], "hello");
     //$mail->AltBody = either($f["altbody"], "To view the message, please use an HTML compatible email viewer!"); // optional, comment out and test
     $mail->AltBody = either($f["msg"], "To view the message, please use an HTML compatible email viewer!");
     // optional, comment out and test
     if ($f["embedimg"]) {
         foreach ($f["embedimg"] as $i) {
             //$mail->AddEmbeddedImage(ROOT."public/images/logo7.png","logo","logo7.png");
             $mail->AddEmbeddedImage($i[0], $i[1], $i[2]);
         }
     }
     if ($f["msgfile"]) {
         $body = $mail->getFile($f["msgfile"]);
         $body = eregi_replace("[\\]", '', $body);
         if ($f["type"] == "text") {
             $mail->IsHTML(false);
             $mail->Body = $body;
         } else {
             $mail->MsgHTML($body);
             //."<br><img src= \"cid:logo\">");
         }
     } else {
         if ($f["type"] == "text") {
             $mail->IsHTML(false);
             $mail->Body = $f["msg"];
         } else {
             $mail->MsgHTML($f["msg"]);
             //."<br><img src= \"cid:logo\">");
         }
     }
     if (preg_match('/\\,/', $f["to"])) {
         $emails = explode(",", $f["to"]);
         foreach ($emails as $i) {
             $mail->AddAddress($i, $f["toname"]);
         }
     } else {
         $mail->AddAddress($f["to"], $f["toname"]);
     }
     $mail->AddBCC($this->config["site"]["mail"], "bcc");
     if ($f["files"]) {
         foreach ($f["files"] as $i) {
             $mail->AddAttachment($i);
             // attachment
         }
     }
     if (!$mail->Send()) {
         return "Mailer Error: " . $mail->ErrorInfo;
     } else {
         return "Message sent!";
     }
 }
Example #15
0
function sendMail($sTo, $sTitle, $sBody, $sFrom, $sBCC = NULL)
{
    global $config;
    $mail = new PHPMailer();
    // SMTP configuration : through gmail
    $mail->IsSMTP();
    // telling the class to use SMTP
    $mail->SMTPDebug = 0;
    // SMTP debug information 0, 1 (errors and messages), 2 (messages only)
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = $config->email->smtpSecurity;
    $mail->Host = $config->email->smtpHost;
    $mail->Port = $config->email->smtpPort;
    $mail->Username = $config->email->smtpUsername;
    $mail->Password = $config->email->smtpPassword;
    // General configuration
    $mail->CharSet = 'UTF-8';
    // Content
    $mail->Subject = $sTitle;
    $mail->Body = $sBody;
    //$mail->MsgHTML($sBody);
    // Emails
    $mail->SetFrom($sFrom, 'Inscription Castor-Informatique');
    $mail->AddReplyTo($sFrom, 'Inscription Castor-Informatique');
    $mail->AddAddress($sTo);
    if (!is_null($sBCC)) {
        $mail->AddBCC($sBCC);
    }
    $bSent = $mail->Send();
    if (!$bSent) {
        echo "Mailer Error: " . $mail->ErrorInfo;
    }
    return $bSent;
}
Example #16
0
 /**
  * send an email
  *
  * @param string $toaddress
  * @param string $toname
  * @param string $subject
  * @param string $mailtext
  * @param string $fromaddress
  * @param string $fromname
  * @param bool $html
  */
 public static function send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '')
 {
     $SMTPMODE = OC_Config::getValue('mail_smtpmode', 'sendmail');
     $SMTPHOST = OC_Config::getValue('mail_smtphost', '127.0.0.1');
     $SMTPAUTH = OC_Config::getValue('mail_smtpauth', false);
     $SMTPUSERNAME = OC_Config::getValue('mail_smtpname', '');
     $SMTPPASSWORD = OC_Config::getValue('mail_smtppassword', '');
     $mailo = new PHPMailer(true);
     if ($SMTPMODE == 'sendmail') {
         $mailo->IsSendmail();
     } elseif ($SMTPMODE == 'smtp') {
         $mailo->IsSMTP();
     } elseif ($SMTPMODE == 'qmail') {
         $mailo->IsQmail();
     } else {
         $mailo->IsMail();
     }
     $mailo->Host = $SMTPHOST;
     $mailo->SMTPAuth = $SMTPAUTH;
     $mailo->Username = $SMTPUSERNAME;
     $mailo->Password = $SMTPPASSWORD;
     $mailo->From = $fromaddress;
     $mailo->FromName = $fromname;
     $mailo->Sender = $fromaddress;
     $a = explode(' ', $toaddress);
     try {
         foreach ($a as $ad) {
             $mailo->AddAddress($ad, $toname);
         }
         if ($ccaddress != '') {
             $mailo->AddCC($ccaddress, $ccname);
         }
         if ($bcc != '') {
             $mailo->AddBCC($bcc);
         }
         $mailo->AddReplyTo($fromaddress, $fromname);
         $mailo->WordWrap = 50;
         if ($html == 1) {
             $mailo->IsHTML(true);
         } else {
             $mailo->IsHTML(false);
         }
         $mailo->Subject = $subject;
         if ($altbody == '') {
             $mailo->Body = $mailtext . OC_MAIL::getfooter();
             $mailo->AltBody = '';
         } else {
             $mailo->Body = $mailtext;
             $mailo->AltBody = $altbody;
         }
         $mailo->CharSet = 'UTF-8';
         $mailo->Send();
         unset($mailo);
         OC_Log::write('mail', 'Mail from ' . $fromname . ' (' . $fromaddress . ')' . ' to: ' . $toname . '(' . $toaddress . ')' . ' subject: ' . $subject, OC_Log::DEBUG);
     } catch (Exception $exception) {
         OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR);
         throw $exception;
     }
 }
Example #17
0
 /**
  * Test BCC-only addressing
  */
 function test_BCCAddressing()
 {
     $this->Mail->Subject .= ': BCC-only addressing';
     $this->BuildBody();
     $this->Mail->ClearAllRecipients();
     $this->assertTrue($this->Mail->AddBCC('*****@*****.**'), 'BCC addressing failed');
     $this->assertTrue($this->Mail->Send(), 'Send failed');
 }
Example #18
0
function phpmail_send($from, $to, $subject, $message, $attachment_path = NULL, $cc = NULL, $bcc = NULL)
{
    require_once APPPATH . 'modules_core/mailer/helpers/phpmailer/class.phpmailer.php';
    $CI =& get_instance();
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    $mail->IsHtml();
    if ($CI->mdl_mcb_data->setting('email_protocol') == 'smtp') {
        $mail->IsSMTP();
        $mail->SMTPAuth = true;
        if ($CI->mdl_mcb_data->setting('smtp_security')) {
            $mail->SMTPSecure = $CI->mdl_mcb_data->setting('smtp_security');
        }
        $mail->Host = $CI->mdl_mcb_data->setting('smtp_host');
        $mail->Port = $CI->mdl_mcb_data->setting('smtp_port');
        $mail->Username = $CI->mdl_mcb_data->setting('smtp_user');
        $mail->Password = $CI->mdl_mcb_data->setting('smtp_pass');
    } elseif ($CI->mdl_mcb_data->setting('email_protocol') == 'sendmail') {
        $mail->IsSendmail();
    }
    if (is_array($from)) {
        $mail->SetFrom($from[0], $from[1]);
    } else {
        $mail->SetFrom($from);
    }
    $mail->Subject = $subject;
    $mail->Body = $message;
    $to = strpos($to, ',') ? explode(',', $to) : explode(';', $to);
    foreach ($to as $address) {
        $mail->AddAddress($address);
    }
    if ($cc) {
        $cc = strpos($cc, ',') ? explode(',', $cc) : explode(';', $cc);
        foreach ($cc as $address) {
            $mail->AddCC($address);
        }
    }
    if ($bcc) {
        $bcc = strpos($bcc, ',') ? explode(',', $bcc) : explode(';', $bcc);
        foreach ($bcc as $address) {
            $mail->AddBCC($address);
        }
    }
    if ($attachment_path) {
        $mail->AddAttachment($attachment_path);
    }
    if ($mail->Send()) {
        if (isset($CI->load->_ci_classes['session'])) {
            $CI->session->set_flashdata('custom_success', $CI->lang->line('email_success'));
            return TRUE;
        }
    } else {
        if (isset($CI->this->load->_ci_classes['session'])) {
            $CI->session->set_flashdata('custom_error', $mail->ErrorInfo);
            return FALSE;
        }
    }
}
Example #19
0
 public function send()
 {
     global $DEVELOPMENT_MODE;
     if ($DEVELOPMENT_MODE) {
         return;
     }
     try {
         if (!$this->textmsg) {
             $this->textmsg = ' ';
         }
         if (!$this->htmlmsg) {
             $this->htmlmsg = ' ';
         }
         require_once '/var/lib/asterisk/agi-bin/phpmailer/class.phpmailer.php';
         $mail = new PHPMailer();
         $mail->IsSMTP();
         $mail->SMTPAuth = true;
         $mail->SMTPSecure = "tls";
         // sets the prefix to the servier
         $mail->Host = "smtp.gmail.com";
         // sets GMAIL as the SMTP server
         $mail->Port = 587;
         // set the SMTP port for the GMAIL server
         $mail->Username = "******";
         // GMAIL username
         $mail->Password = "******";
         // GMAIL password
         $mail->SetFrom('*****@*****.**', 'Asterisk @ Taaza Stores');
         $mail->AddReplyTo('*****@*****.**', 'Asterisk @ Taaza Stores');
         if (count($this->Attachments)) {
             $attachmentCount = count($this->Attachments);
             for ($t = 0; $t < $attachmentCount; $t++) {
                 if (@$this->AttachmentNames[$t]) {
                     $mail->AddAttachment($this->Attachments[$t], $this->AttachmentNames[$t]);
                 } else {
                     $mail->AddAttachment($this->Attachments[$t]);
                 }
             }
         }
         if (count($this->BCCS)) {
             foreach ($this->BCCS as $bccid) {
                 $mail->AddBCC($bccid);
             }
         }
         $mail->AddAddress($this->mailto);
         $mail->Subject = $this->subject;
         $mail->AltBody = $this->textmsg;
         $mail->MsgHTML($this->htmlmsg);
         $mail->Send();
     } catch (phpmailerException $e) {
         echo $e->errorMessage();
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
Example #20
0
function sendemail($toname, $toemail, $fromname, $fromemail, $subject, $message, $type = "plain", $cc = "", $bcc = "")
{
    global $settings, $locale;
    require_once INCLUDES . "class.phpmailer.php";
    $mail = new PHPMailer();
    if (file_exists(INCLUDES . "language/phpmailer.lang-" . $locale['phpmailer'] . ".php")) {
        $mail->SetLanguage($locale['phpmailer'], INCLUDES . "language/");
    } else {
        $mail->SetLanguage("en", INCLUDES . "language/");
    }
    if (!$settings['smtp_host']) {
        $mail->IsMAIL();
    } else {
        $mail->IsSMTP();
        $mail->Host = $settings['smtp_host'];
        $mail->Port = $settings['smtp_port'];
        $mail->SMTPAuth = $settings['smtp_auth'] ? true : false;
        $mail->Username = $settings['smtp_username'];
        $mail->Password = $settings['smtp_password'];
    }
    $mail->CharSet = $locale['charset'];
    $mail->From = $fromemail;
    $mail->FromName = $fromname;
    $mail->AddAddress($toemail, $toname);
    $mail->AddReplyTo($fromemail, $fromname);
    if ($cc) {
        $cc = explode(", ", $cc);
        foreach ($cc as $ccaddress) {
            $mail->AddCC($ccaddress);
        }
    }
    if ($bcc) {
        $bcc = explode(", ", $bcc);
        foreach ($bcc as $bccaddress) {
            $mail->AddBCC($bccaddress);
        }
    }
    if ($type == "plain") {
        $mail->IsHTML(false);
    } else {
        $mail->IsHTML(true);
    }
    $mail->Subject = $subject;
    $mail->Body = $message;
    if (!$mail->Send()) {
        $mail->ErrorInfo;
        $mail->ClearAllRecipients();
        $mail->ClearReplyTos();
        return false;
    } else {
        $mail->ClearAllRecipients();
        $mail->ClearReplyTos();
        return true;
    }
}
Example #21
0
 public function Send(IEmailMessage $emailMessage)
 {
     $this->phpMailer->ClearAllRecipients();
     $this->phpMailer->ClearReplyTos();
     $this->phpMailer->CharSet = $emailMessage->Charset();
     $this->phpMailer->Subject = $emailMessage->Subject();
     $this->phpMailer->Body = $emailMessage->Body();
     $from = $emailMessage->From();
     $defaultFrom = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_ADDRESS);
     $defaultName = Configuration::Instance()->GetSectionKey(ConfigSection::EMAIL, ConfigKeys::DEFAULT_FROM_NAME);
     $address = empty($defaultFrom) ? $from->Address() : $defaultFrom;
     $name = empty($defaultName) ? $from->Name() : $defaultName;
     $this->phpMailer->SetFrom($address, $name);
     $replyTo = $emailMessage->ReplyTo();
     $this->phpMailer->AddReplyTo($replyTo->Address(), $replyTo->Name());
     $to = $this->ensureArray($emailMessage->To());
     $toAddresses = new StringBuilder();
     foreach ($to as $address) {
         $toAddresses->Append($address->Address());
         $this->phpMailer->AddAddress($address->Address(), $address->Name());
     }
     $cc = $this->ensureArray($emailMessage->CC());
     foreach ($cc as $address) {
         $this->phpMailer->AddCC($address->Address(), $address->Name());
     }
     $bcc = $this->ensureArray($emailMessage->BCC());
     foreach ($bcc as $address) {
         $this->phpMailer->AddBCC($address->Address(), $address->Name());
     }
     if ($emailMessage->HasStringAttachment()) {
         Log::Debug('Adding email attachment %s', $emailMessage->AttachmentFileName());
         $this->phpMailer->AddStringAttachment($emailMessage->AttachmentContents(), $emailMessage->AttachmentFileName());
     }
     Log::Debug('Sending %s email to: %s from: %s', get_class($emailMessage), $toAddresses->ToString(), $from->Address());
     $success = false;
     try {
         $success = $this->phpMailer->Send();
     } catch (Exception $ex) {
         Log::Error('Failed sending email. Exception: %s', $ex);
     }
     Log::Debug('Email send success: %d. %s', $success, $this->phpMailer->ErrorInfo);
 }
 private function convert_mail()
 {
     foreach ($this->mail_to_send->get_recipients() as $recipient => $name) {
         $this->mailer->AddAddress($recipient, $name);
     }
     // cc
     foreach ($this->mail_to_send->get_cc_recipients() as $recipient => $name) {
         $this->mailer->AddCC($recipient, $name);
     }
     // bcc
     foreach ($this->mail_to_send->get_bcc_recipients() as $recipient => $name) {
         $this->mailer->AddBCC($recipient, $name);
     }
     // from
     $this->mailer->SetFrom($this->mail_to_send->get_sender_mail(), $this->mail_to_send->get_sender_name());
     $this->mailer->AddReplyTo($this->mail_to_send->get_reply_to_mail() ? $this->mail_to_send->get_reply_to_mail() : $this->mail_to_send->get_sender_mail(), $this->mail_to_send->get_reply_to_name() ? $this->mail_to_send->get_reply_to_name() : $this->mail_to_send->get_sender_name());
     $this->mailer->Subject = $this->mail_to_send->get_subject();
     // content
     $this->convert_content();
 }
 /**
  * Adds all of the addresses
  * @access public
  * @param string $sAddress
  * @param string $sName
  * @param string $sType
  * @return boolean
  */
 function SetAddress($sAddress, $sName = '', $sType = 'to')
 {
     switch ($sType) {
         case 'to':
             return $this->Mail->AddAddress($sAddress, $sName);
         case 'cc':
             return $this->Mail->AddCC($sAddress, $sName);
         case "bcc":
             return $this->Mail->AddBCC($sAddress, $sName);
     }
     return false;
 }
Example #24
0
 function newUser($validator)
 {
     $email = $validator->getVar("email");
     $q = Doctrine_Query::create()->from('user u')->where("u.email='{$email}'");
     $rows = $q->execute();
     $random = rand(0, 999999999);
     if (count($rows) == 0) {
         $random = rand(0, 999999999);
         $entity = new user();
         $entity->email = $email;
         $entity->password = $validator->getVar("password");
         $entity->validation_code = $random;
         $entity->save();
     } else {
         $validator->addError('The user "' . $email . '" already exists.');
     }
     $idUsuario = mysql_insert_id();
     if ($validator->getTotalErrors() == 0) {
         require_once 'phputils/class.phpmailer.php';
         try {
             $mail = new PHPMailer(true);
             //New instance, with exceptions enabled
             //$body             = file_get_contents('contents.html');
             $body = 'Hi ' . $email . ', Welcome!, your validation code is ' . $random . '. Before you can log into the system you must click on the following link: ' . $GLOBALS["baseURL"] . 'crud.php?public_action=validate&a=' . $random . '&b=' . $entity->id;
             $body = preg_replace('/\\\\/', '', $body);
             //Strip backslashes
             //$mail->IsSMTP();                           // tell the class to use SMTP
             //$mail->SMTPAuth   = true;                  // enable SMTP authentication
             //$mail->Port       = 587;                    // set the SMTP server port
             //$mail->Host       = "smtp.gmail.com"; // SMTP server
             //$mail->Username   = "******";     // SMTP server username
             //$mail->Password   = "";            // SMTP server password
             //$mail->IsSendmail();  // tell the class to use Sendmail
             //$mail->AddReplyTo("*****@*****.**","domain.com");
             $mail->From = "*****@*****.**";
             $mail->FromName = "Domain.com";
             $mail->AddBCC($email);
             $mail->Subject = "Domain.com Registration";
             $mail->AltBody = 'Hi ' . $email . ', welcome!, your validation code is ' . $random . '. Before you can log into the system you must copy the following link into you browser: ' . $GLOBALS["baseURL"] . 'crud.php?public_action=validate&a=' . $random . '&b=' . $entity->id;
             $mail->WordWrap = 80;
             // set word wrap
             $mail->MsgHTML($body);
             $mail->IsHTML(true);
             // send as HTML
             $mail->Send();
             $_SESSION['user']->status = 'pending';
             $_SESSION['user']->name = $email;
         } catch (phpmailerException $e) {
             //$validator->addError("PHPMailer:".$e->errorMessage());
         }
     }
     return 'controller.php?view=validate';
 }
 function send()
 {
     $mail = new PHPMailer();
     $mail->SMTPDebug = $this->SMTPDebug;
     $mail->IsSMTP();
     // set mailer to use SMTP
     $mail->SMTPAuth = $this->SMTPAuth;
     //設定SMTP需要驗證
     $mail->SMTPSecure = $this->SMTPSecure;
     // Gmail的SMTP主機需要使用SSL連線
     $mail->Host = $this->Host;
     //Gamil的SMTP主機
     $mail->Port = $this->Port;
     //Gamil的SMTP主機的SMTP埠位為465埠。
     $mail->CharSet = $this->CharSet;
     //設定郵件編碼
     $mail->Username = $this->UserName;
     $mail->Password = $this->Password;
     $mail->From = $this->from;
     $mail->FromName = $this->fromName;
     foreach ($this->to as $to_address) {
         $mail->AddAddress($to_address['email'], $to_address['name']);
     }
     foreach ($this->cc as $to_address) {
         $mail->AddCC($to_address['email'], $to_address['name']);
     }
     foreach ($this->bcc as $to_address) {
         $mail->AddBCC($to_address['email'], $to_address['name']);
     }
     $mail->AddReplyTo($this->from, $this->fromName);
     $mail->WordWrap = 50;
     // set word wrap to 50 characters
     if (!empty($this->attachments)) {
         foreach ($this->attachments as $attachment) {
             if (empty($attachment['asfile'])) {
                 $mail->AddAttachment($attachment['filename']);
             } else {
                 $mail->AddAttachment($attachment['filename'], $attachment['asfile']);
             }
         }
     }
     $mail->IsHTML(true);
     // set email format to HTML
     $mail->Subject = $this->subject;
     $mail->Body = $this->html_body;
     //設定郵件內容
     $result = $mail->Send();
     if ($result === false) {
         $result = $mail->ErrorInfo;
     }
     return $result;
 }
Example #26
0
 function send($o, $to, $from, $subject, $body, $headers)
 {
     $mail = new PHPMailer(true);
     $mail->IsSMTP();
     $mail->SMTPDebug = 0;
     // enables SMTP debug information (for testing)
     $mail->SMTPAuth = $this->api->getConfig("tmail/phpmailer/username", null) ? true : false;
     // enable SMTP authentication
     $mail->Host = $this->api->getConfig("tmail/smtp/host");
     $mail->Port = $this->api->getConfig("tmail/smtp/port");
     $mail->Username = $this->api->getConfig("tmail/phpmailer/username", null);
     $mail->Password = $this->api->getConfig("tmail/phpmailer/password", null);
     $mail->SMTPSecure = 'tls';
     $mail->AddReplyTo($this->api->getConfig("tmail/phpmailer/reply_to"), $this->api->getConfig("tmail/phpmailer/reply_to_name"));
     $mail->AddAddress($to);
     $mail->Subject = $subject;
     $mail->MsgHTML($body);
     $mail->AltBody = null;
     $mail->IsHTML(true);
     $bcc = $this->api->getConfig("tmail/phpmailer/bcc", null);
     if ($bcc) {
         $bcc_name = $this->api->getConfig("tmail/phpmailer/bcc_name", null);
         $mail->AddBCC($bcc, $bcc_name);
     }
     $internal_header_map = array("Content-Type" => "ContentType");
     $void_headers = array("MIME-Version");
     $fromAdded = false;
     foreach (explode("\n", $headers) as $h) {
         if (preg_match("/^(.*?):(.*)\$/", $h, $t)) {
             if (strtolower($t[1]) == "from" && $t[2]) {
                 $mail->SetFrom($t[2]);
                 $fromAdded = true;
                 continue;
             }
             if (isset($internal_header_map[$t[1]])) {
                 $key = $internal_header_map[$t[1]];
                 $mail->{$key} = $t[2];
                 continue;
             } else {
                 if (in_array($t[1], $void_headers)) {
                     continue;
                 }
             }
         }
         $mail->AddCustomHeader($h);
     }
     if (!$fromAdded) {
         $mail->SetFrom($this->api->getConfig("tmail/phpmailer/from"), $from ? "" : $this->api->getConfig("tmail/phpmailer/from_name"));
         $mail->AddReplyTo($this->api->getConfig("tmail/phpmailer/reply_to"), $this->api->getConfig("tmail/phpmailer/reply_to_name"));
     }
     $mail->Send();
 }
Example #27
0
 public function addAddressToMailer($type, $addr)
 {
     if (empty($addr)) {
         return;
     }
     $a = array_filter(array_map('trim', explode(',', $addr)));
     foreach ($a as $address) {
         switch ($type) {
             case 'to':
                 $this->mail->AddAddress($address);
                 break;
             case 'cc':
                 $this->mail->AddCC($address);
                 break;
             case 'bcc':
                 $this->mail->AddBCC($address);
                 break;
             case 'replyTo':
                 $this->mail->AddReplyTo($address);
         }
     }
 }
Example #28
0
		public function sendSMTP($recipient=false, $subject, $content){
			$smtp_server 	= MAIL_SMTP_SERVER;
			$port 			= MAIL_SMTP_SERVER_PORT;
			$mydomain 		= MAIL_SMTP_DOMAIN;
			$username 		= MAIL_SMTP_USERNAME; // MS Exchange servers will probably require a valid NT domain name as part of the username. E.g., "ntdomainuser"
			$password 		= MAIL_SMTP_PASSWORD;		
			$sender 		= MAIL;
			
            
			require_once('source/lib/smtp/class.phpmailer.php');
            include("source/lib/smtp/class.smtp.php");
			$mail = new PHPMailer(false); // true = throw exceptions
			
			
			$mail->IsSMTP(); // use SMTP
			           			
			try {
				$mail->Host       = MAIL_SMTP_SERVER;
				$mail->SMTPDebug  = false;
				$mail->SMTPAuth   = true;
				$mail->Port       = MAIL_SMTP_SERVER_PORT;
				$mail->Username   = MAIL_SMTP_USERNAME;
				$mail->Password   = MAIL_SMTP_PASSWORD;
                $mail->SMTPSecure = 'ssl';
				
				if(!is_array($recipient)){
					$mail->AddAddress($recipient, '');
				} else {
					foreach($recipient as $r)
						$mail->AddBCC($r, '');
				}
				
				$mail->SetFrom(MAIL, PAGE_NAME);
				$mail->Subject = $subject;
		
				$mail->MsgHTML(utf8_decode($content));
	
				//$mail->AddReplyTo(MAIL, 'First Last');
				//$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!'; // optional - MsgHTML will create an alternate automatically
				//$mail->AddAttachment('images/phpmailer.gif');      // attachment
				//$mail->AddAttachment('images/phpmailer_mini.gif'); // attachment
		
				$mail->Send();
			  	//echo "Message Sent OK</p>\n";
			} catch (phpmailerException $e) {
				echo $e->errorMessage(); //Pretty error messages from PHPMailer
			} catch (Exception $e) {
				echo $e->getMessage(); //Boring error messages from anything else!
			}
		}
Example #29
0
 function SendMail($toAddress, $toName, $subject, $messageBody, $bcc = NULL, $mailList = FALSE)
 {
     require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/Main.php";
     if ($mailList) {
         require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/MailService2.php";
     } else {
         require $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "Config/MailService.php";
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/class.phpmailer.php";
     require_once $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/class.pop3.php";
     if ($MailServiceAuthPOP3) {
         $pop = new POP3();
         $pop->Authorise($MailServicePOP3Addr, $MailServicePOP3Port, 30, $MailServiceSMTPUser, $MailServiceSMTPPass, $MailServicePOPDebug);
     }
     $mail = new PHPMailer();
     if ($MailServiceMailerLang != "en") {
         $mail->SetLanguage($MailServiceMailerLang, $_SERVER['DOCUMENT_ROOT'] . "/" . $_SESSION['SiteFolder'] . "System/PHPMailer/language/");
     }
     $mail->IsSMTP();
     $mail->SMTPDebug = $MailServiceSMTPDebug;
     $mail->Port = $MailServiceSMTPPort;
     $mail->SMTPSecure = $MailServiceEncrypt;
     $mail->Host = $MailServiceSMTPAddr;
     $mail->SMTPAuth = $MailServiceAuthSMTP;
     $mail->Username = $MailServiceSMTPUser;
     $mail->Password = $MailServiceSMTPPass;
     $mail->From = $MailServiceFromMail;
     $mail->FromName = $MailServiceFromName;
     $mail->AddAddress($toAddress, $toName);
     if ($bcc != NULL) {
         if (is_array($bcc)) {
             foreach ($bcc as $key => $value) {
                 $mail->AddBCC($value);
             }
         }
     }
     $mail->WordWrap = 50;
     $mail->CharSet = $MailServiceMsgCharset;
     $mail->IsHTML(true);
     $mail->Subject = $subject;
     $mail->Body = $messageBody;
     if ($mail->Send()) {
         return true;
     } else {
         return $mail->ErrorInfo;
     }
 }
Example #30
0
 public function OlvidarContrasena($validator)
 {
     $emailString = $validator->getVar('emails');
     $random = rand(0, 999999999);
     $pass = sha1($random);
     $result = $validator->exect("SELECT * FROM `user` WHERE email='{$emailString}'");
     $obj = mysql_fetch_object($result);
     if ($obj && $obj->status == "valid") {
         $record = Doctrine::getTable("User")->find($obj->id);
         $record->password = $pass;
         $record->save();
         require_once 'phputils/class.phpmailer.php';
         try {
             $mail = new PHPMailer(true);
             //New instance, with exceptions enabled
             //$body             = file_get_contents('contents.html');
             $body = 'Hi ' . $emailString . ', you have requested to be reminded of your password. Your new password is ' . $random . ', if you have not request this password remind please <a href="#">click here</a> and fill you complaint.';
             $body = preg_replace('/\\\\/', '', $body);
             //Strip backslashes
             //$mail->IsSMTP();                           // tell the class to use SMTP
             //$mail->SMTPAuth   = true;                  // enable SMTP authentication
             //$mail->Port       = 587;                    // set the SMTP server port
             //$mail->Host       = "smtp.gmail.com"; // SMTP server
             //$mail->Username   = "******";     // SMTP server username
             //$mail->Password   = "******";            // SMTP server password
             //$mail->IsSendmail();  // tell the class to use Sendmail
             //$mail->AddReplyTo("*****@*****.**","domain.com");
             $mail->From = "*****@*****.**";
             $mail->FromName = "IVoted.com";
             $mail->AddBCC($emailString);
             $mail->Subject = "IVoted.com password remind.";
             $mail->AltBody = 'Hi ' . $emailString . ', you have requested to be reminded of your password. Your new password is ' . $random . ', if you have not request this password remind please reply this email with your complaint.';
             $mail->WordWrap = 80;
             // set word wrap
             $mail->MsgHTML($body);
             $mail->IsHTML(true);
             // send as HTML
             $mail->Send();
         } catch (phpmailerException $e) {
             //$validator->addError("PHPMailer:".$e->errorMessage());
         }
         return 'controller.php?view=login';
     } else {
         return 'controller.php?view=validate';
     }
 }