Example #1
1
function sendMail($to, $subject, $message, $fromAddress = '', $fromUserName = '', $toName = '', $bcc = '', $upload_dir = '', $filename = '')
{
    $mail = new PHPMailer();
    $mail->IsSMTP();
    $mail->Host = "mail.taggerzz.com";
    $mail->Port = 25;
    $mail->IsSendmail();
    $mail->IsHTML(true);
    $mail->ClearAddresses();
    $find = strpos($to, ',');
    if ($find) {
        $ids = explode(',', $to);
        for ($i = 0; $i < count($ids); $i++) {
            $mail->AddAddress($ids[$i]);
        }
    } else {
        $mail->AddAddress($to);
    }
    if ($fromAddress != '') {
        $mail->From = $fromAddress;
    } else {
        $mail->From = "*****@*****.**";
    }
    if ($fromUserName != '') {
        $mail->FromName = $fromUserName;
    } else {
        $mail->FromName = "TAGGERZZ";
    }
    $mail->WordWrap = 50;
    $mail->IsHTML(true);
    $mail->Subject = $subject;
    $mail->Body = $message;
    if ($upload_dir != '') {
        foreach ($upload_dir as $uploaddirs) {
            $mail->AddAttachment($uploaddirs, $filename);
        }
    }
    if ($mail->Send()) {
        return 1;
    } else {
        return 0;
    }
}
Example #2
0
function Sendemail($to, $subject, $message, $repyto, $from, $fromname)
{
    try {
        $mail = new PHPMailer(true);
        //New instance, with exceptions enabled
        $mail->IsSMTP();
        // tell the class to use SMTP
        $mail->SMTPAuth = false;
        // enable SMTP authentication
        $mail->IsSendmail();
        // tell the class to use Sendmail
        $mail->AddReplyTo($repyto, $fromname);
        $mail->From = $from;
        $mail->FromName = $fromname;
        $mail->AddAddress($to);
        $mail->Subject = $subject;
        $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
        // optional, comment out and test
        $mail->WordWrap = 80;
        // set word wrap
        $mail->MsgHTML($message);
        $mail->IsHTML(true);
        // send as HTML
        $mail->Send();
        return true;
    } catch (phpmailerException $e) {
        //echo $e->errorMessage();
    }
}
 public function PFMailSend($sender, $param)
 {
     $Aufgabe = ProtokollDetailAufgabeView::finder()->findByidtm_protokoll_detail($param->CallbackParameter);
     $MailEmpfaenger = OrganisationRecord::finder()->findByPk($Aufgabe->idtm_organisation);
     $mail = new PHPMailer();
     $mail->From = "*****@*****.**";
     $mail->FromName = "planlogIQ";
     $mail->Host = "smtp.1und1.de";
     $mail->Mailer = "smtp";
     $mail->SMTPAuth = true;
     $mail->IsSendmail();
     //nur bei 1und1
     $mail->Username = "******";
     $mail->Password = "";
     $mail->AddAddress(KommunikationRecord::finder()->find('idtm_organisation=? AND kom_ismain=1 AND kom_type = 3', $Aufgabe->idtm_organisation)->kom_information, $MailEmpfaenger->org_name);
     $mail->Subject = $Aufgabe->prtdet_topic;
     $HTMLMessage = "Sehr geehrte(r) Frau/Herr " . $MailEmpfaenger->org_name . ",<br/><br/>";
     $HTMLMessage .= "die folgende Aufgabe wurde Ihnen zugeordnet:<br/>";
     $HTMLMessage .= "<p><table><tr><td bgcolor='#efefef'>TOP Nr.:</td><td>" . $Aufgabe->idtm_protokoll_detail_group . " </td><td bgcolor='#efefef'>Thema: </td><td>" . utf8_decode($Aufgabe->prtdet_topic) . "</td></tr>";
     $HTMLMessage .= "<tr><td bgcolor='#efefef'>Bis:</td><td colspan='3'><b>" . $Aufgabe->auf_tdate . "</b></td></tr></table>";
     $HTMLMessage .= "<p style='background-color:#efefef'><hr/>" . utf8_decode($Aufgabe->prtdet_descr) . "</p>";
     $HTMLMessage .= "<p style='background-color:#efefef'><hr/>" . utf8_decode($Aufgabe->auf_beschreibung) . "<hr/></p>";
     $HTMLMessage .= "Bitte nicht Antworten! Diese Mail wurde automatisch generiert...";
     $mail->MsgHTML($HTMLMessage);
     if (!$mail->Send()) {
         $this->PFMAILER->TEXT = "error sending the message";
     } else {
         $this->PFMAILER->TEXT = "..done..";
     }
 }
 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!";
     }
 }
function dest_mail()
{
    global $WORKING, $STATIC;
    $WORKING['STEPTODO'] = filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']);
    $WORKING['STEPDONE'] = 0;
    trigger_error(sprintf(__('%d. try to sending backup with mail...', 'backwpup'), $WORKING['DEST_MAIL']['STEP_TRY']), E_USER_NOTICE);
    //Create PHP Mailer
    require_once realpath($STATIC['WP']['ABSPATH'] . $STATIC['WP']['WPINC']) . '/class-phpmailer.php';
    $phpmailer = new PHPMailer();
    //Setting den methode
    if ($STATIC['CFG']['mailmethod'] == "SMTP") {
        require_once realpath($STATIC['WP']['ABSPATH'] . $STATIC['WP']['WPINC']) . '/class-smtp.php';
        $phpmailer->Host = $STATIC['CFG']['mailhost'];
        $phpmailer->Port = $STATIC['CFG']['mailhostport'];
        $phpmailer->SMTPSecure = $STATIC['CFG']['mailsecure'];
        $phpmailer->Username = $STATIC['CFG']['mailuser'];
        $phpmailer->Password = base64_decode($STATIC['CFG']['mailpass']);
        if (!empty($STATIC['CFG']['mailuser']) and !empty($STATIC['CFG']['mailpass'])) {
            $phpmailer->SMTPAuth = true;
        }
        $phpmailer->IsSMTP();
        trigger_error(__('Send mail with SMTP', 'backwpup'), E_USER_NOTICE);
    } elseif ($STATIC['CFG']['mailmethod'] == "Sendmail") {
        $phpmailer->Sendmail = $STATIC['CFG']['mailsendmail'];
        $phpmailer->IsSendmail();
        trigger_error(__('Send mail with Sendmail', 'backwpup'), E_USER_NOTICE);
    } else {
        $phpmailer->IsMail();
        trigger_error(__('Send mail with PHP mail', 'backwpup'), E_USER_NOTICE);
    }
    trigger_error(__('Creating mail', 'backwpup'), E_USER_NOTICE);
    $phpmailer->From = $STATIC['CFG']['mailsndemail'];
    $phpmailer->FromName = $STATIC['CFG']['mailsndname'];
    $phpmailer->AddAddress($STATIC['JOB']['mailaddress']);
    $phpmailer->Subject = sprintf(__('BackWPup archive from %1$s: %2$s', 'backwpup'), date('Y/m/d @ H:i', $STATIC['JOB']['starttime'] + $STATIC['WP']['TIMEDIFF']), $STATIC['JOB']['name']);
    $phpmailer->IsHTML(false);
    $phpmailer->Body = sprintf(__('Backup archive: %s', 'backwpup'), $STATIC['backupfile']);
    //check file Size
    if (!empty($STATIC['JOB']['mailefilesize'])) {
        if (filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']) > abs($STATIC['JOB']['mailefilesize'] * 1024 * 1024)) {
            trigger_error(__('Backup archive too big for sending by mail!', 'backwpup'), E_USER_ERROR);
            $WORKING['STEPDONE'] = 1;
            $WORKING['STEPSDONE'][] = 'DEST_MAIL';
            //set done
            return;
        }
    }
    trigger_error(__('Adding backup archive to mail', 'backwpup'), E_USER_NOTICE);
    need_free_memory(filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']) * 5);
    $phpmailer->AddAttachment($STATIC['JOB']['backupdir'] . $STATIC['backupfile']);
    trigger_error(__('Send mail....', 'backwpup'), E_USER_NOTICE);
    if (false == $phpmailer->Send()) {
        trigger_error(sprintf(__('Error "%s" on sending mail!', 'backwpup'), $phpmailer->ErrorInfo), E_USER_ERROR);
    } else {
        $WORKING['STEPTODO'] = filesize($STATIC['JOB']['backupdir'] . $STATIC['backupfile']);
        trigger_error(__('Mail send!!!', 'backwpup'), E_USER_NOTICE);
    }
    $WORKING['STEPSDONE'][] = 'DEST_MAIL';
    //set done
}
Example #6
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 #7
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 #8
0
 /**
  * Test sending using SendMail
  */
 function test_SendmailSend()
 {
     $this->Mail->Body = "Sending via sendmail";
     $this->BuildBody();
     $subject = $this->Mail->Subject;
     $this->Mail->Subject = $subject . ": sendmail";
     $this->Mail->IsSendmail();
     $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
 }
function sendReportEmail($to, $from = "*****@*****.**", $content = "nuBuilder Email", $html = false, $subject = "", $wordWrap = 120, $filesource, $filename, $receipt = "false")
{
    $mail = new PHPMailer();
    // BEGIN - 2009/06/09 - Michael
    switch ($GLOBALS["NUMailMethod"]) {
        // Use the sendmail binary.
        case "sendmail":
            $mail->IsSendmail();
            break;
            // case
            // Use an SMTP server to send the mail.
        // case
        // Use an SMTP server to send the mail.
        case "smtp":
            $mail->IsSMTP();
            $mail->Host = !empty($GLOBALS["NUSMTPHost"]) ? $GLOBALS["NUSMTPHost"] : "127.0.0.1";
            $mail->SMTPAuth = !empty($GLOBALS["NUSMTPUsername"]) ? true : false;
            if ($mail->SMTPAuth) {
                $mail->Username = !empty($GLOBALS["NUSMTPUsername"]) ? $GLOBALS["NUSMTPUsername"] : "";
                $mail->Password = !empty($GLOBALS["NUSMTPPassword"]) ? $GLOBALS["NUSMTPPassword"] : "";
            }
            // if
            // case
            // Use PHP's built-in mail function.
        // case
        // Use PHP's built-in mail function.
        case "mail":
        default:
            // Nothing to do, "mail" is the PHPMailer default.
            // default
    }
    // switch
    // END - 2009/06/09 - Michael
    if ($receipt == "true") {
        $mail->ConfirmReadingTo = $from;
    }
    if (empty($from)) {
        $mail->From = '*****@*****.**';
    } else {
        $mail->From = $from;
    }
    $mail->FromName = $fromname;
    $toArray = explode(',', $to);
    for ($i = 0; $i < count($toArray); $i++) {
        if ($toArray[$i]) {
            $mail->AddAddress($toArray[$i]);
        }
    }
    $mail->WordWrap = $wordWrap;
    $mail->IsHTML($html);
    $mail->AddAttachment($filesource, $filename);
    $mail->Subject = $subject;
    $mail->Body = $content;
    return $mail->Send();
}
 public function sendMailSMTP($template, $to, $data)
 {
     require 'PHPMailer/class.phpmailer.php';
     $file = file($template);
     //Get values from template mail
     foreach ($file as $value) {
         if ($value != "") {
             list($key, $val) = explode("=>", $value);
             $key = trim($key);
             $val = trim($val);
             ${$key} = $val;
         }
     }
     $body = str_replace('\\r\\n', '<br/>', $body);
     try {
         $mail = new PHPMailer(true);
         //New instance, with exceptions enabled
         $mail->IsSMTP();
         // tell the class to use SMTP
         $mail->SMTPAuth = true;
         // enable SMTP authentication
         $mail->Port = 25;
         // set the SMTP server port
         $mail->Host = "mail.gmail.com";
         // SMTP server
         $mail->Username = $from;
         // SMTP server username
         $mail->Password = "";
         // SMTP server password
         $mail->IsSendmail();
         // tell the class to use Sendmail
         $mail->AddReplyTo($from, "Brights consulting");
         $mail->From = $from;
         $mail->FromName = "Brights consulting";
         $mail->AddAddress($to);
         $mail->Subject = $subject;
         $mail->AltBody = $body;
         // optional, comment out and test
         $mail->WordWrap = 80;
         // set word wrap
         $mail->MsgHTML($body);
         $mail->IsHTML(true);
         // send as HTML
         if ($mail->Send()) {
             return true;
         }
     } catch (phpmailerException $e) {
         $e->errorMessage();
     }
 }
Example #11
0
    /**
     * Test sending using SendMail
     */
    function test_SendmailSend()
    {
	    // If this medium is not enabled, do not test it!
	    if($this->Mail->Mailer != 'sendmail'){
		    $this->markTestSkipped('sendmail not enabled, skipping send test');
		    return;
	    }

        $this->Mail->Body = "Sending via sendmail";
        $this->BuildBody();
        $subject = $this->Mail->Subject;

        $this->Mail->Subject = $subject . ": sendmail";
        $this->Mail->IsSendmail();
        $this->assertTrue($this->Mail->Send(), $this->Mail->ErrorInfo);
    }
Example #12
0
 /**
  * Constructor.
  */
 function __construct()
 {
     require_once PHPMAILER_CLASS;
     require_once PHPMAILER_SMTP;
     require_once PHPMAILER_POP3;
     // Inicializa la instancia PHPMailer.
     $mail = new \PHPMailer();
     // Define  el idioma para los mensajes de error.
     $mail->SetLanguage("es", PHPMAILER_LANGS);
     // Define la codificación de caracteres del mensaje.
     $mail->CharSet = "UTF-8";
     // Define el ajuste de texto a un número determinado de caracteres en el cuerpo del mensaje.
     $mail->WordWrap = 50;
     // Define el tipo de gestor de correo
     switch (GOTEO_MAIL_TYPE) {
         default:
         case "mail":
             $mail->isMail();
             // set mailer to use PHP mail() function.
             break;
         case "sendmail":
             $mail->IsSendmail();
             // set mailer to use $Sendmail program.
             break;
         case "qmail":
             $mail->IsQmail();
             // set mailer to use qmail MTA.
             break;
         case "smtp":
             $mail->IsSMTP();
             // set mailer to use SMTP
             $mail->SMTPAuth = GOTEO_MAIL_SMTP_AUTH;
             // enable SMTP authentication
             $mail->SMTPSecure = GOTEO_MAIL_SMTP_SECURE;
             // sets the prefix to the servier
             $mail->Host = GOTEO_MAIL_SMTP_HOST;
             // specify main and backup server
             $mail->Port = GOTEO_MAIL_SMTP_PORT;
             // set the SMTP port
             $mail->Username = GOTEO_MAIL_SMTP_USERNAME;
             // SMTP username
             $mail->Password = GOTEO_MAIL_SMTP_PASSWORD;
             // SMTP password
             break;
     }
     $this->mail = $mail;
 }
Example #13
0
 function send_basic_text_email($email_tos, $email_ccs, $email_subject, $email_message)
 {
     //following code adapted from phpMailer 2.2.1 README
     $mail = new PHPMailer();
     if (AppSettings::gv("smtp_server") == "localhost") {
         $mail->IsSendmail();
     } else {
         $mail->IsSMTP();
         // set mailer to use SMTP
         $mail->Host = AppSettings::gv("smtp_server");
         // specify main and backup server
         $mail->SMTPAuth = true;
         // turn on SMTP authentication
         $mail->Username = AppSettings::gv("smtp_user");
         // SMTP username
         $mail->Password = AppSettings::gv("smtp_pass");
         // SMTP password
     }
     $mail->From = AppSettings::gv("std_email_from");
     $mail->FromName = "New England Trade";
     foreach ($email_tos as $email_to) {
         //$mail->AddAddress("*****@*****.**", "Josh Adams");
         //$mail->AddAddress("*****@*****.**");                  // name is optional
         $mail->AddAddress($email_to);
         //echo "yo:".$email_to;
     }
     foreach ($email_ccs as $email_cc) {
         $mail->AddCC($email_cc);
     }
     //$mail->AddReplyTo("*****@*****.**", "Information");
     $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->Subject = $email_subject;
     $mail->Body = $email_message;
     //$mail->AltBody = "This is the body in plain text for non-HTML mail clients";
     if (!$mail->Send()) {
         echo "Message could not be sent. <p>";
         echo "Mailer Error: " . $mail->ErrorInfo . " ++";
         echo "<p>Developer note: Maybe the email address is invalid? Please try changing the user email address. <a href='/index.php'>Go back</a> to site.";
         exit;
     }
     return true;
     //echo "Message has been sent";
 }
Example #14
0
function send_mail($mail_to, $mail_body, $mail_subject = 'No title', $mail_name = 'No name', $mail_from = '', $mail_priority = 3, $mail_wordwrap = 50, $mail_altbody = '')
{
    global $GO_CONFIG;
    //	$mail_to='*****@*****.**';
    //	$mail_from = '*****@*****.**';
    //	$mail_name = "333";
    //	$mail_subject = 'subject';
    //	$mail_body = '123456789';
    //	$mail_altbody = 'qqqqqqqqqqqqqqqq';
    require $GO_CONFIG->class_path . "phpmailer/class.phpmailer.php";
    require $GO_CONFIG->class_path . "phpmailer/class.smtp.php";
    $mail = new PHPMailer();
    $mail->PluginDir = $GO_CONFIG->class_path . 'phpmailer/';
    $mail->SetLanguage($php_mailer_lang, $GO_CONFIG->class_path . 'phpmailer/language/');
    switch ($GO_CONFIG->mailer) {
        case 'smtp':
            $mail->Host = $GO_CONFIG->smtp_server;
            $mail->Port = $GO_CONFIG->smtp_port;
            $mail->IsSMTP();
            break;
        case 'qmail':
            $mail->IsQmail();
            break;
        case 'sendmail':
            $mail->IsSendmail();
            break;
        case 'mail':
            $mail->IsMail();
            break;
    }
    $mail->Priority = $mail_priority;
    $mail->Sender = $mail_from;
    $mail->From = $mail_from;
    $mail->FromName = $mail_name;
    $mail->AddReplyTo($mail_from, $mail_name);
    $mail->WordWrap = $mail_wordwrap;
    //    $mail->Encoding = "quoted-printable";
    $mail->IsHTML(true);
    $mail->Subject = $mail_subject;
    $mail->AddAddress($mail_to);
    $mail->Body = $mail_body;
    $mail->AltBody = $mail_altbody;
    if (!$mail->Send()) {
        return '<p class="Error">' . $ml_send_error . ' ' . $mail->ErrorInfo . '</p>';
    }
}
 public static function enviareEmail($body)
 {
     try {
         $mail = new PHPMailer(true);
         //New instance, with exceptions enabled
         $body = file_get_contents($body);
         $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.googlemail.com";
         // SMTP server
         $mail->Username = "";
         // SMTP server username
         $mail->Password = "";
         // SMTP server password
         $mail->IsSendmail();
         // tell the class to use Sendmail
         $mail->AddReplyTo("", "Egberto Monteiro");
         $mail->From = "";
         $mail->FromName = "Egberto Monteiro";
         $to = "";
         $mail->AddAddress($to);
         $mail->Subject = "First PHPMailer Message";
         $mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
         // optional, comment out and test
         $mail->WordWrap = 80;
         // set word wrap
         $mail->MsgHTML($body);
         $mail->IsHTML(true);
         // send as HTML
         $mail->Send();
         echo 'Message has been sent.';
     } catch (phpmailerException $e) {
         echo $e->errorMessage();
     }
 }
Example #16
0
function send_mail($to, $subj, $msg)
{
    global $CONF, $CONF_MAIL, $dbConnection;
    if (get_conf_param('mail_type') == "sendmail") {
        $mail = new PHPMailer();
        $mail->CharSet = 'UTF-8';
        $mail->IsSendmail();
        $mail->AddReplyTo($CONF_MAIL['from'], $CONF['name_of_firm']);
        $mail->AddAddress($to, $to);
        $mail->SetFrom($CONF_MAIL['from'], $CONF['name_of_firm']);
        $mail->Subject = $subj;
        $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
        $mail->MsgHTML($msg);
        $mail->Send();
    } else {
        if (get_conf_param('mail_type') == "SMTP") {
            $mail = new PHPMailer();
            $mail->CharSet = 'UTF-8';
            $mail->IsSMTP();
            $mail->SMTPAuth = $CONF_MAIL['auth'];
            // enable SMTP authentication
            if (get_conf_param('mail_auth_type') != "none") {
                $mail->SMTPSecure = $CONF_MAIL['auth_type'];
            }
            $mail->Host = $CONF_MAIL['host'];
            $mail->Port = $CONF_MAIL['port'];
            $mail->Username = $CONF_MAIL['username'];
            $mail->Password = $CONF_MAIL['password'];
            $mail->AddReplyTo($CONF_MAIL['from'], $CONF['name_of_firm']);
            $mail->AddAddress($to, $to);
            $mail->SetFrom($CONF_MAIL['from'], $CONF['name_of_firm']);
            $mail->Subject = $subj;
            $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
            // optional - MsgHTML will create an alternate automatically
            $mail->MsgHTML($msg);
            $mail->Send();
        }
    }
}
 public function PFMailSend($sender, $param)
 {
     $Aufgabe = AufgabenRecord::finder()->findByPK($sender->CommandParameter);
     $mail = new PHPMailer();
     $mail->From = "*****@*****.**";
     $mail->FromName = "planlogIQ";
     $mail->Host = "smtp.1und1.de";
     $mail->Mailer = "smtp";
     $mail->SMTPAuth = true;
     $mail->IsSendmail();
     //nur bei 1und1
     $mail->Username = "******";
     $mail->Password = "";
     $mail->AddAddress(KommunikationRecord::finder()->find('idtm_organisation=? AND kom_ismain=1 AND kom_type = 3', $Aufgabe->auf_idtm_organisation)->kom_information, OrganisationRecord::finder()->findByPK($Aufgabe->auf_idtm_organisation)->org_name);
     $mail->Subject = $Aufgabe->auf_name;
     $mail->MsgHTML($Aufgabe->auf_beschreibung);
     if (!$mail->Send()) {
         $this->PFMAILER->TEXT = "There was an error sending the message";
     } else {
         $this->PFMAILER->TEXT = "..done..";
     }
 }
function mail_attachment($to, $clientEmail, $subject, $message, $from, $file)
{
    $mail = new PHPMailer();
    // defaults to using php "mail()"
    $mail->IsSendmail();
    // telling the class to use SendMail transport
    $mail->SetFrom($from, '');
    $mail->AddAddress($to, "");
    $mail->AddBCC($clientEmail, '');
    $mail->Subject = $subject;
    $body = $message;
    //$mail->AltBody    = $message; // optional, comment out and test
    $mail->MsgHTML($body);
    $mail->AddAttachment($file);
    // attachment
    if (!$mail->Send()) {
        // echo "Mailer Error: " .
        return $mail->ErrorInfo;
    } else {
        //  echo
        return "Message sent!";
    }
}
Example #19
0
 function sendMail()
 {
     global $_CONFIG;
     require_once __DIR__ . "/../lib/3rdparty/phpmailer/class.phpmailer.php";
     if (count($_POST) > 0 && !$this->enabled()) {
         return FALSE;
     }
     if (!filter_var($_POST['from_email'], FILTER_VALIDATE_EMAIL)) {
         return FALSE;
     }
     $mail = new PHPMailer();
     if (array_key_exists('smtp_server', $_CONFIG)) {
         $mail->IsSMTP();
         // $mail->SMTPDebug = 2;
         // $mail->Debugoutput = 'html';
         $mail->Host = $_CONFIG['smtp_server'];
         $mail->Port = $_CONFIG['smtp_port'];
         $mail->SMTPAuth = TRUE;
         $mail->SMTPSecure = $_CONFIG['smtp_security'];
         $mail->Username = $_CONFIG['smtp_username'];
         $mail->Password = $_CONFIG['smtp_password'];
     } else {
         $mail->IsSendmail();
     }
     $mail->setFrom($_POST['from_email']);
     $mail->AddAddress($_CONFIG['email_address']);
     $mail->Subject = preg_replace("|[^a-zA-Z0-9.;:@'\"/\\!\\? ]|", ' ', $_POST['subject']);
     $mail->Body = $_POST['message'];
     $sendResult = $mail->Send();
     if (!$sendResult) {
         error_log("Mailer Error: " . $mail->ErrorInfo);
         return FALSE;
     } else {
         $_POST = array();
         return TRUE;
     }
 }
 public function Send()
 {
     try {
         $mail = new PHPMailer(true);
         //New instance, with exceptions enabled
         $initInfo = \Utility\GlobalConfiguration::GetInstance()->Config[\Constant\SectionType::Mail];
         $body = $this->getBody($this->username, $this->password);
         $mail->IsSMTP();
         // tell the class to use SMTP
         $mail->SMTPAuth = true;
         // enable SMTP authentication
         $mail->Port = 465;
         // set the SMTP server port
         $mail->Host = $initInfo[\Constant\ConfigKey::Host];
         // SMTP server
         $mail->Username = $initInfo[\Constant\ConfigKey::Username];
         // SMTP server username
         $mail->Password = $initInfo[\Constant\ConfigKey::Password];
         // SMTP server password
         $mail->IsSendmail();
         // tell the class to use Sendmail
         $mail->AddReplyTo($initInfo[\Constant\ConfigKey::From], $initInfo[\Constant\ConfigKey::FromName]);
         $mail->From = $initInfo[\Constant\ConfigKey::From];
         $mail->FromName = $initInfo[\Constant\ConfigKey::FromName];
         $mail->AddAddress($this->toMail);
         $mail->Subject = $initInfo[\Constant\ConfigKey::Subject];
         $mail->WordWrap = 80;
         // set word wrap
         $mail->MsgHTML($body);
         $mail->IsHTML(true);
         // send as HTML
         $mail->Send();
         return NULL;
     } catch (phpmailerException $e) {
         return $body . '######1#######' . $e->errorMessage();
     }
 }
function xmail($to, $from = array(), $topic, $comment)
{
    global $config, $gpc;
    require_once "classes/mail/class.phpmailer.php";
    $mail = new PHPMailer();
    $mail->CharSet = 'UTF-8';
    // Added Check_mail for better security
    // Now it is not possible to add various headers to the mail
    if (!isset($from['mail']) || !check_mail($from['mail'])) {
        $mail->From = $config['forenmail'];
    } else {
        $mail->From = $gpc->plain_str($from['mail']);
    }
    if (!isset($from['name'])) {
        $mail->FromName = $gpc->plain_str($config['fname']);
    } else {
        $mail->FromName = $gpc->plain_str($from['name']);
    }
    if ($config['smtp'] == 1) {
        $mail->Mailer = "smtp";
        $mail->IsSMTP();
        $mail->Host = $config['smtp_host'];
        if ($config['smtp_auth'] == 1) {
            $mail->SMTPAuth = TRUE;
            $mail->Username = $config['smtp_username'];
            $mail->Password = $config['smtp_password'];
        }
    } elseif ($config['sendmail'] == 1) {
        $mail->IsSendmail();
        $mail->Mailer = "sendmail";
        $mail->Sendmail = $config['sendmail_host'];
    } else {
        $mail->IsMail();
    }
    $mail->Subject = $gpc->plain_str($topic);
    if (!is_array($to)) {
        $to = array('0' => array('mail' => $to));
    }
    $i = 0;
    foreach ($to as $email) {
        $mail->IsHTML(false);
        $mail->Body = $gpc->plain_str($comment);
        if (isset($email['name'])) {
            $mail->AddAddress($gpc->plain_str($email['mail']), $gpc->plain_str($email['name']));
        } else {
            $mail->AddAddress($gpc->plain_str($email['mail']));
        }
        if ($config['local_mode'] == 0) {
            if ($mail->Send()) {
                $i++;
            }
        }
        $mail->ClearAddresses();
        $mail->ClearAttachments();
    }
    return $i;
}
Example #22
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();
    }
}
Example #23
0
	$mail = new PHPMailer();
	$mail->From = $data['from_mail'];
	$mail->FromName = $data['from_name'];
	$mail->Subject = $data['title'];
	if ($config['smtp'] == 1) {
		$mail->Mailer = "smtp";
		$mail->IsSMTP();
		$mail->Host = $config['smtp_host'];
		if ($config['smtp_auth'] == 1) {
			$mail->SMTPAuth = true;
			$mail->Username = $config['smtp_username'];
			$mail->Password = $config['smtp_password'];
		}
	}
	elseif ($config['sendmail'] == 1) {
		$mail->IsSendmail();
		$mail->Mailer   = "sendmail";
		$mail->Sendmail = $config['sendmail_host'];
	}
	else {
		$mail->IsMail();
	}
	$ids = implode(',', $data['chunks'][$page-1]);
	$result = $db->query("SELECT id, name, mail FROM {$db->pre}user WHERE id IN ($ids)");
	while ($row = $db->fetch_assoc($result)) {
		$message = str_replace('{$user.id}', $row['id'], $data['message']);
		$message = str_replace('{$user.name}', $row['name'], $message);
		$message = str_replace('{$user.mail}', $row['mail'], $message);
		if ($data['type'] == 'h') {
			$mail->IsHTML(true);
			$mail->Body = $message;
/**
* This function mails a text $body to the recipient $to.
* You can use more than one recipient when using a semikolon separated string with recipients.
*
* @param string $body Body text of the email in plain text or HTML
* @param mixed $subject Email subject
* @param mixed $to Array with several email addresses or single string with one email address
* @param mixed $from
* @param mixed $sitename
* @param mixed $ishtml
* @param mixed $bouncemail
* @param mixed $attachment
* @return bool If successful returns true
*/
function SendEmailMessage($body, $subject, $to, $from, $sitename, $ishtml = false, $bouncemail = null, $attachments = null, $customheaders = "")
{
    global $maildebug, $maildebugbody;
    $emailmethod = Yii::app()->getConfig('emailmethod');
    $emailsmtphost = Yii::app()->getConfig("emailsmtphost");
    $emailsmtpuser = Yii::app()->getConfig("emailsmtpuser");
    $emailsmtppassword = Yii::app()->getConfig("emailsmtppassword");
    $emailsmtpdebug = Yii::app()->getConfig("emailsmtpdebug");
    $emailsmtpssl = Yii::app()->getConfig("emailsmtpssl");
    $defaultlang = Yii::app()->getConfig("defaultlang");
    $emailcharset = Yii::app()->getConfig("emailcharset");
    if ($emailcharset != 'utf-8') {
        $body = mb_convert_encoding($body, $emailcharset, 'utf-8');
        $subject = mb_convert_encoding($subject, $emailcharset, 'utf-8');
        $sitename = mb_convert_encoding($sitename, $emailcharset, 'utf-8');
    }
    if (!is_array($to)) {
        $to = array($to);
    }
    if (!is_array($customheaders) && $customheaders == '') {
        $customheaders = array();
    }
    if (Yii::app()->getConfig('demoMode')) {
        $maildebug = gT('Email was not sent because demo-mode is activated.');
        $maildebugbody = '';
        return false;
    }
    if (is_null($bouncemail)) {
        $sender = $from;
    } else {
        $sender = $bouncemail;
    }
    require_once APPPATH . '/third_party/phpmailer/class.phpmailer.php';
    $mail = new PHPMailer();
    if (!$mail->SetLanguage($defaultlang, APPPATH . '/third_party/phpmailer/language/')) {
        $mail->SetLanguage('en', APPPATH . '/third_party/phpmailer/language/');
    }
    $mail->CharSet = $emailcharset;
    if (isset($emailsmtpssl) && trim($emailsmtpssl) !== '' && $emailsmtpssl !== 0) {
        if ($emailsmtpssl === 1) {
            $mail->SMTPSecure = "ssl";
        } else {
            $mail->SMTPSecure = $emailsmtpssl;
        }
    }
    $fromname = '';
    $fromemail = $from;
    if (strpos($from, '<')) {
        $fromemail = substr($from, strpos($from, '<') + 1, strpos($from, '>') - 1 - strpos($from, '<'));
        $fromname = trim(substr($from, 0, strpos($from, '<') - 1));
    }
    $sendername = '';
    $senderemail = $sender;
    if (strpos($sender, '<')) {
        $senderemail = substr($sender, strpos($sender, '<') + 1, strpos($sender, '>') - 1 - strpos($sender, '<'));
        $sendername = trim(substr($sender, 0, strpos($sender, '<') - 1));
    }
    switch ($emailmethod) {
        case "qmail":
            $mail->IsQmail();
            break;
        case "smtp":
            $mail->IsSMTP();
            if ($emailsmtpdebug > 0) {
                $mail->SMTPDebug = $emailsmtpdebug;
            }
            if (strpos($emailsmtphost, ':') > 0) {
                $mail->Host = substr($emailsmtphost, 0, strpos($emailsmtphost, ':'));
                $mail->Port = substr($emailsmtphost, strpos($emailsmtphost, ':') + 1);
            } else {
                $mail->Host = $emailsmtphost;
            }
            $mail->Username = $emailsmtpuser;
            $mail->Password = $emailsmtppassword;
            if (trim($emailsmtpuser) != "") {
                $mail->SMTPAuth = true;
            }
            break;
        case "sendmail":
            $mail->IsSendmail();
            break;
        default:
            //Set to the default value to rule out incorrect settings.
            $emailmethod = "mail";
            $mail->IsMail();
    }
    $mail->SetFrom($fromemail, $fromname);
    $mail->Sender = $senderemail;
    // Sets Return-Path for error notifications
    foreach ($to as $singletoemail) {
        if (strpos($singletoemail, '<')) {
            $toemail = substr($singletoemail, strpos($singletoemail, '<') + 1, strpos($singletoemail, '>') - 1 - strpos($singletoemail, '<'));
            $toname = trim(substr($singletoemail, 0, strpos($singletoemail, '<') - 1));
            $mail->AddAddress($toemail, $toname);
        } else {
            $mail->AddAddress($singletoemail);
        }
    }
    if (is_array($customheaders)) {
        foreach ($customheaders as $key => $val) {
            $mail->AddCustomHeader($val);
        }
    }
    $mail->AddCustomHeader("X-Surveymailer: {$sitename} Emailer (LimeSurvey.sourceforge.net)");
    if (get_magic_quotes_gpc() != "0") {
        $body = stripcslashes($body);
    }
    if ($ishtml) {
        $mail->IsHTML(true);
        if (strpos($body, "<html>") === false) {
            $body = "<html>" . $body . "</html>";
        }
        $mail->msgHTML($body, App()->getConfig("publicdir"));
        // This allow embedded image if we remove the servername from image
    } else {
        $mail->IsHTML(false);
        $mail->Body = $body;
    }
    // Add attachments if they are there.
    if (is_array($attachments)) {
        foreach ($attachments as $attachment) {
            // Attachment is either an array with filename and attachment name.
            if (is_array($attachment)) {
                $mail->AddAttachment($attachment[0], $attachment[1]);
            } else {
                // Or a string with the filename.
                $mail->AddAttachment($attachment);
            }
        }
    }
    $mail->Subject = $subject;
    if ($emailsmtpdebug > 0) {
        ob_start();
    }
    $sent = $mail->Send();
    $maildebug = $mail->ErrorInfo;
    if ($emailsmtpdebug > 0) {
        $maildebug .= '<li>' . gT('SMTP debug output:') . '</li><pre>' . strip_tags(ob_get_contents()) . '</pre>';
        ob_end_clean();
    }
    $maildebugbody = $mail->Body;
    //if(!$sent) var_dump($maildebug);
    return $sent;
}
Example #25
0
     $send_mail->IsSMTP();
     // set mailer to use SMTP
     $send_mail->SMTPAuth = OOS_SMTPAUTH;
     // turn on SMTP authentication
     $send_mail->Username = OOS_SMTPUSER;
     // SMTP username
     $send_mail->Password = OOS_SMTPPASS;
     // SMTP password
     $send_mail->Host = OOS_SMTPHOST;
     // specify main and backup server
 } else {
     // Set sendmail path
     if (EMAIL_TRANSPORT == 'sendmail') {
         if (!oos_empty(OOS_SENDMAIL)) {
             $send_mail->Sendmail = OOS_SENDMAIL;
             $send_mail->IsSendmail();
         }
     }
 }
 $send_mail->Subject = $subject;
 $send_mail->Body = $message;
 $send_mail->AddAddress($_POST['email_to'], 'Friend');
 $send_mail->Send();
 $send_mail->ClearAddresses();
 $send_mail->ClearAttachments();
 // Now create the coupon email entry
 $couponstable = $oostable['coupons'];
 $insert_result = $dbconn->Execute("INSERT INTO {$couponstable} (coupon_code, coupon_type, coupon_amount, date_created) VALUES ('" . $id1 . "', 'G', '" . $_POST['amount'] . "', '" . date("Y-m-d H:i:s", time()) . "')");
 $insert_id = $dbconn->Insert_ID();
 $coupon_email_tracktable = $oostable['coupon_email_track'];
 $insert_result = $dbconn->Execute("INSERT INTO {$coupon_email_tracktable} (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) VALUES ('" . $insert_id . "', '0', 'Admin', '" . $_POST['email_to'] . "', '" . date("Y-m-d H:i:s", time()) . "' )");
Example #26
0
File: test.php Project: vobinh/PHP
 private function send_email_outlook($record)
 {
     $html_content = Data_template_Model::get_value('EMAIL_TESTING');
     if (isset($this->sess_cus['name']) && !empty($this->sess_cus['name'])) {
         $name = $this->sess_cus['name'];
     } else {
         $name = $this->sess_cus['email'];
     }
     $html_content = str_replace('#name#', $name, $html_content);
     //if(isset($record['testing_score']) && !empty($record['testing_score']))
     $test = $this->test_model->get($record['test_uid']);
     $html_content = str_replace('#test#', isset($test['test_title']) ? $test['test_title'] : '', $html_content);
     $html_content = str_replace('#date#', $this->format_int_date($record['testing_date'], $this->site['site_short_date']), $html_content);
     $html_content = str_replace('#score#', $record['testing_score'], $html_content);
     $html_content = str_replace('#duration#', gmdate("H:i:s", $record['duration']), $html_content);
     $html_content = str_replace('#code#', $record['testing_code'], $html_content);
     $html_content = str_replace('#site#', $this->site['site_name'], $html_content);
     $mail = new PHPMailer(true);
     // the true param means it will throw exceptions on errors, which we need to catch
     $mail->IsSendmail();
     // telling the class to use SendMail transport
     $mail->IsHTML(true);
     $mail->IsSMTP();
     $mail->CharSet = "windows-1251";
     $mail->CharSet = "utf-8";
     try {
         $mail->SMTPSecure = 'ssl';
         // secure transfer enabled REQUIRED for Gmail
         $mail->SMTPAuth = true;
         $mail->Port = 465;
         $mail->SMTPDebug = 0;
         $arr_email = explode('@', $this->sess_cus['email']);
         if (isset($arr_email[1]) && $arr_email[1] == 'gmail.com') {
             $mail->Host = 'smtp.gmail.com';
             $gmail = array('*****@*****.**', '*****@*****.**', '*****@*****.**');
             $mail->Username = $gmail[array_rand($gmail)];
             $mail->Password = '******';
             $mail->From = "*****@*****.**";
             $mail->FromName = "PesTest.com";
             $mail->Sender = "*****@*****.**";
         } else {
             $mail->Host = 'pestest.com';
             $mail->Username = '******';
             $mail->Password = '******';
             $mail->From = "*****@*****.**";
             $mail->FromName = "PesTest.com";
             $mail->Sender = "*****@*****.**";
         }
         $mail->SetFrom($this->site['site_email'], 'Pestest.com');
         $mail->AddAddress($this->sess_cus['email']);
         // $mail->AddAddress($this->site['site_email']);
         $mail->Subject = 'Testing ' . $this->site['site_name'];
         $mail->Body = $html_content;
         if ($mail->Send()) {
             return true;
         } else {
             return false;
         }
     } catch (phpmailerException $e) {
         //echo $e->errorMessage(); //Pretty error messages from PHPMailer
     } catch (Exception $e) {
         //echo $e->getMessage(); //Boring error messages from anything else!
     }
 }
function vam_php_mail($from_email_address, $from_email_name, $to_email_address, $to_name, $forwarding_to, $reply_address, $reply_address_name, $path_to_attachement, $path_to_more_attachements, $email_subject, $message_body_html, $message_body_plain)
{
    global $mail_error;
    $mail = new PHPMailer();
    $mail->PluginDir = DIR_FS_DOCUMENT_ROOT . 'includes/external/phpmailer/';
    if (isset($_SESSION['language_charset'])) {
        $mail->CharSet = $_SESSION['language_charset'];
    } else {
        $lang_query = "SELECT * FROM " . TABLE_LANGUAGES . " WHERE code = '" . DEFAULT_LANGUAGE . "'";
        $lang_query = vam_db_query($lang_query);
        $lang_data = vam_db_fetch_array($lang_query);
        $mail->CharSet = $lang_data['language_charset'];
    }
    if ($_SESSION['language'] == 'russian') {
        $mail->SetLanguage("ru", DIR_FS_DOCUMENT_ROOT . 'includes/external/phpmailer/language/');
    } else {
        $mail->SetLanguage("en", DIR_FS_DOCUMENT_ROOT . 'includes/external/phpmailer/language/');
    }
    if (EMAIL_TRANSPORT == 'smtp') {
        $mail->IsSMTP();
        $mail->SMTPKeepAlive = true;
        // set mailer to use SMTP
        $mail->SMTPAuth = SMTP_AUTH;
        // turn on SMTP authentication true/false
        $mail->Username = SMTP_USERNAME;
        // SMTP username
        $mail->Password = SMTP_PASSWORD;
        // SMTP password
        $mail->Host = SMTP_MAIN_SERVER . ';' . SMTP_Backup_Server;
        // specify main and backup server "smtp1.example.com;smtp2.example.com"
    }
    if (EMAIL_TRANSPORT == 'sendmail') {
        // set mailer to use SMTP
        $mail->IsSendmail();
        $mail->Sendmail = SENDMAIL_PATH;
    }
    if (EMAIL_TRANSPORT == 'mail') {
        $mail->IsMail();
    }
    if (EMAIL_USE_HTML == 'true') {
        $mail->IsHTML(true);
        $mail->Body = $message_body_html;
        // remove html tags
        $message_body_plain = str_replace('<br />', " \n", $message_body_plain);
        $message_body_plain = strip_tags($message_body_plain);
        $mail->AltBody = $message_body_plain;
    } else {
        $mail->IsHTML(false);
        //remove html tags
        $message_body_plain = str_replace('<br />', " \n", $message_body_plain);
        $message_body_plain = strip_tags($message_body_plain);
        $mail->Body = $message_body_plain;
    }
    $mail->From = $from_email_address;
    $mail->Sender = $from_email_address;
    $mail->FromName = $from_email_name;
    $mail->AddAddress($to_email_address, $to_name);
    if ($forwarding_to != '') {
        $mail->AddBCC($forwarding_to);
    }
    //$mail->AddReplyTo($reply_address, $reply_address_name);
    $mail->WordWrap = 100;
    // set word wrap to 50 characters
    //$mail->AddAttachment($path_to_attachement);                     // add attachments
    //$mail->AddAttachment($path_to_more_attachements);               // optional name
    $mail->Subject = $email_subject;
    if (SEND_EMAILS == 'true') {
        if (!$mail->Send()) {
            echo TEXT_PHP_MAILER_ERROR;
            echo TEXT_PHP_MAILER_ERROR1 . $mail->ErrorInfo;
            exit;
        }
    }
}
  /**
   * Mail function (uses phpMailer)
   */
  function oos_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {


    if (preg_match('~[\r\n]~', $to_name)) return false;
    if (preg_match('~[\r\n]~', $to_email_address)) return false;
    if (preg_match('~[\r\n]~', $email_subject)) return false;
    if (preg_match('~[\r\n]~', $from_email_name)) return false;
    if (preg_match('~[\r\n]~', $from_email_address)) return false;

    $sLang = (isset($_SESSION['iso_639_1']) ? $_SESSION['iso_639_1'] : 'en');

    // Instantiate a new mail object
    $mail = new PHPMailer;

    $mail->PluginDir = OOS_ABSOLUTE_PATH . 'includes/lib/phpmailer/';
    $mail->SetLanguage( $sLang, OOS_ABSOLUTE_PATH . 'includes/lib/phpmailer/language/' );

    $mail->CharSet = CHARSET;
    $mail->IsMail();

    $mail->From = $from_email_address ? $from_email_address : STORE_OWNER_EMAIL_ADDRESS;
    $mail->FromName = $from_email_name ? $from_email_name : STORE_OWNER;
    $mail->Mailer = EMAIL_TRANSPORT;

    // Add smtp values if needed
    if ( EMAIL_TRANSPORT == 'smtp' ) {
      $mail->IsSMTP(); // set mailer to use SMTP
      $mail->SMTPAuth = OOS_SMTPAUTH; // turn on SMTP authentication
      $mail->Username = OOS_SMTPUSER; // SMTP username
      $mail->Password = OOS_SMTPPASS; // SMTP password
      $mail->Host     = OOS_SMTPHOST; // specify main and backup server
    } else
      // Set sendmail path
      if ( EMAIL_TRANSPORT == 'sendmail' ) {
        if (!oos_empty(OOS_SENDMAIL)) {
          $mail->Sendmail = OOS_SENDMAIL;
          $mail->IsSendmail();
        }
    }


    $mail->AddAddress($to_email_address, $to_name);
    $mail->Subject = $email_subject;


    // Build the text version
    $text = strip_tags($email_text);
    if (EMAIL_USE_HTML == '1') {
      $mail->IsHTML(true);
      $mail->Body = $email_text;
      $mail->AltBody = $text;
    } else {
      $mail->Body = $text;
    }

    // Send message
    $mail->Send();
  }
Example #29
0
function smtp_mail($sendto_email, $subject, $body, $From = '', $FromName = '')
{
    global $_CFG;
    require_once QISHI_ROOT_PATH . 'phpmailer/class.phpmailer.php';
    $mail = new PHPMailer();
    $mailconfig = get_cache('mailconfig');
    $mailconfig['smtpservers'] = explode('|-_-|', $mailconfig['smtpservers']);
    $mailconfig['smtpusername'] = explode('|-_-|', $mailconfig['smtpusername']);
    $mailconfig['smtppassword'] = explode('|-_-|', $mailconfig['smtppassword']);
    $mailconfig['smtpfrom'] = explode('|-_-|', $mailconfig['smtpfrom']);
    $mailconfig['smtpport'] = explode('|-_-|', $mailconfig['smtpport']);
    for ($i = 0; $i < count($mailconfig['smtpservers']); $i++) {
        $mailconfigarray[] = array('smtpservers' => $mailconfig['smtpservers'][$i], 'smtpusername' => $mailconfig['smtpusername'][$i], 'smtppassword' => $mailconfig['smtppassword'][$i], 'smtpfrom' => $mailconfig['smtpfrom'][$i], 'smtpport' => $mailconfig['smtpport'][$i]);
    }
    $mc = array_rand($mailconfigarray, 1);
    $mc = $mailconfigarray[$mc];
    $mailconfig['smtpservers'] = $mc['smtpservers'];
    $mailconfig['smtpusername'] = $mc['smtpusername'];
    $mailconfig['smtppassword'] = $mc['smtppassword'];
    $mailconfig['smtpfrom'] = $mc['smtpfrom'];
    $mailconfig['smtpport'] = $mc['smtpport'];
    $From = $From ? $From : $mailconfig['smtpfrom'];
    $FromName = $FromName ? $FromName : $_CFG['site_name'];
    if ($mailconfig['method'] == "1") {
        if (empty($mailconfig['smtpservers']) || empty($mailconfig['smtpusername']) || empty($mailconfig['smtppassword']) || empty($mailconfig['smtpfrom'])) {
            write_syslog(2, 'MAIL', "邮件配置信息不完整");
            return false;
        }
        $mail->IsSMTP();
        $mail->Host = $mailconfig['smtpservers'];
        $mail->SMTPDebug = 0;
        $mail->SMTPAuth = true;
        $mail->Username = $mailconfig['smtpusername'];
        $mail->Password = $mailconfig['smtppassword'];
        $mail->Port = $mailconfig['smtpport'];
        $mail->From = $mailconfig['smtpfrom'];
        $mail->FromName = $FromName;
    } elseif ($mailconfig['method'] == "2") {
        $mail->IsSendmail();
    } elseif ($mailconfig['method'] == "3") {
        $mail->IsMail();
    }
    $mail->CharSet = QISHI_CHARSET;
    $mail->Encoding = "base64";
    $mail->AddReplyTo($From, $FromName);
    $mail->AddAddress($sendto_email, "");
    $mail->IsHTML(true);
    $mail->Subject = $subject;
    $mail->Body = $body;
    $mail->AltBody = "text/html";
    if ($mail->Send()) {
        write_sys_email_log($mailconfig['smtpusername'], $sendto_email, $subject, $body, "1");
        return true;
    } else {
        write_syslog(2, 'MAIL', $mail->ErrorInfo);
        write_sys_email_log($mailconfig['smtpusername'], $sendto_email, $subject, $body, "2");
        return false;
    }
}
Example #30
-1
function mailer($from, $from_email, $to, $to_email, $subject, $content, $files)
{
    $content = nl2br($content);
    $mail = new PHPMailer(true);
    $mail->IsSendmail();
    try {
        $mail->CharSet = "utf-8";
        $mail->Encoding = "base64";
        $mail->AddAddress($to_email, $to);
        $mail->SetFrom($from_email, $from);
        $mail->AddReplyTo($from_email, $from);
        $mail->Subject = $subject;
        $mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
        $mail->MsgHTML($content);
        if ($files[1] != "") {
            $mail->AddAttachment("./temp/" . $files[1]);
        }
        if ($files[2] != "") {
            $mail->AddAttachment("./temp/" . $files[2]);
        }
        if ($files[3] != "") {
            $mail->AddAttachment("./temp/" . $files[3]);
        }
        $mail->Send();
        return true;
    } catch (phpmailerException $e) {
        echo $e->errorMessage();
        return false;
    } catch (Exception $e) {
        echo $e->getMessage();
        return false;
    }
}