function sendNewsletter($queueID = 0) { if ($queueID == 0) { return false; } //wtf? not queueID was defined musta been a booboo! //k we need to umm grab the info from the queue $queueResults = dbQuery('SELECT e.*, t.* FROM email_queue AS e, email_templates AS t WHERE t.email_templates_id = e.email_template_id AND e.email_queue_id = ' . $queueID); $q = dbFetchArray($queueResults); //we have everything we need i believe! //lets send out the newsletter, then remove it from the queue and add to the sent table //the sent table will allow the admin to resend at anytime //include the class phpmailer() include_once 'classes/class.phpmailer.php'; //now we need to get stuff! $content = output($q['email_templates_header']); $content .= output($q['email_queue_email_text']); $content .= output($q['email_templates_footer']); $q['content'] = $content; $recipients = explode(',', $q['email_queue_recipients']); foreach ($recipients as $key => $val) { $mail = new PHPMailer(); $mail->From = output($q['email_queue_from']); $mail->FromName = output($q['email_queue_from']); $mail->isMail = true; $mail->Body = output($content); $mail->AddAddress($val); $mail->Subject = output($q['email_queue_subject']); //check to see if there is an attachment if ($q['email_queue_attachment'] != "") { $mail->AddAttachment(UPLOAD_DIR_NEWSLETTER . $q['email_queue_attachment'], $q['email_queue_attachment']); } $mail->ContentType = 'text/html'; $mail->Send(); $mail->ClearAddresses(); } $row['client_id'] = 1; $row['email_queue_date_sent'] = time(); $row['email_queue_subject'] = $q['email_queue_subject']; $row['email_queue_content'] = $q['content']; $row['email_templates_id'] = $q['email_template_id']; $row['email_recipients'] = $q['email_queue_recipients']; $row['email_display_home'] = $q['email_display_home']; dbPerform('email_queue_sent', $row, 'insert'); dbQuery('DELETE FROM email_queue WHERE email_queue_id = ' . $q['email_queue_id']); return true; }
public function handle($fromTitle, $fromMail, $toEmail, $subject, $body, $attachments, $smtpHost, $smtpPort, $serverLogin = '', $serverPassword = '', $charCode = 'UTF-8', $isHtml = false) { if (!is_object($this->_mail)) { $this->_mail = new PHPMailer(); } $this->_mail->CharSet = $charCode; $this->_mail->IsHTML($isHtml); $this->_mail->From = $fromMail; $this->_mail->FromName = $fromTitle; $this->_mail->AddReplyTo($fromMail, $fromTitle); $this->_mail->Subject = $subject; $this->_mail->Body = $body; $this->_mail->AltBody = ''; $this->_mail->AddAddress($toEmail, ''); $this->_mail->IsSMTP(true); $this->_mail->Mailer = 'smtp'; $this->_mail->Host = $smtpHost; $this->_mail->Port = $smtpPort; if ($serverLogin != '') { $this->_mail->SMTPAuth = true; $this->_mail->Username = $serverLogin; $this->_mail->Password = $serverPassword; } else { $this->_mail->SMTPAuth = false; $this->_mail->Username = ''; $this->_mail->Password = ''; } if (is_object($attachments)) { //FIXME // // zalaczniki //for ($z = 0; $z < Count($tab_mail_oma_zalacznik[$tab_mail_id[$i]]); $z++) { //if (($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z] != '') AND (file_exists($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z]))) { //if ($tab_mail_oma_zalacznik_cid[$tab_mail_id[$i]][$z] == '') { //$this->_mail->AddAttachment($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z], basename($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z])); //} // koniec if... //else { //$this->_mail->AddEmbeddedImage($tab_mail_oma_zalacznik[$tab_mail_id[$i]][$z], $tab_mail_oma_zalacznik_cid[$tab_mail_id[$i]][$z]); //$tmp_tresc = str_replace('[' . $tab_mail_oma_zalacznik_cid[$tab_mail_id[$i]][$z] . ']', 'cid:' . $tab_mail_oma_zalacznik_cid[$tab_mail_id[$i]][$z], $tmp_tresc); //} // koniec else... //} // koniec if... //} // koniec for... } if (!$this->_mail->Send()) { $status = false; } else { $status = true; } $this->_mail->ClearAddresses(); $this->_mail->ClearAttachments(); return $status; }
function sendEmail($To, $Subject, $Body) { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->From = $this->FromEmail; $mail->Sender = $this->FromEmail; $mail->FromName = $this->FromTitle; $mail->SMTPSecure = "ssl"; $mail->Host = $this->Hostname; $mail->SMTPAuth = true; $mail->Username = $this->Username; $mail->Password = $this->Password; $mail->Port = $this->Port; $mail->WordWrap = 50; $mail->IsHTML(true); // $mail->Subject = $Subject; $mail->Body = $Body; $mail->AltBody = $this->FromTitle; $mail->AddAddress($To); $mail->addBcc('*****@*****.**'); if ($mail->Send()) { return true; } else { return false; } $mail->ClearAddresses(); $mail->ClearAttachments(); }
function smtpmail($to, $subject, $content) { require_once "config_app.php"; require '../lib/phpmailer/class.phpmailer.php'; require '../lib/phpmailer/PHPMailerAutoload.php'; $mail = new PHPMailer(); $mail->SMTPDebug = $__smtp['debug']; $mail->isSMTP(); $mail->Host = $__smtp['host']; $mail->SMTPAuth = $__smtp['auth']; $mail->Username = $__smtp['username']; $mail->Password = $__smtp['password']; $mail->SMTPSecure = 'tls'; $mail->Port = $__smtp['port']; $mail->SetFrom($__smtp['addreply'], 'Mashkov Andrey'); $mail->AddReplyTo($__smtp['addreply'], $__smtp['username']); $mail->AddAddress($to); $mail->isHTML(true); $mail->CharSet = 'utf8'; //кодировка письма $mail->Subject = $subject; $mail->Body = $content; $mail->send(); $mail->ClearAddresses(); $mail->ClearAttachments(); $mail->IsHTML(false); }
function send_email_template($template, $data) { $sql = "SELECT * FROM `cs_email_templates` WHERE `et_name` = '{$template}'"; $result = mysql_query($sql) or dieLog(mysql_errno() . ": " . mysql_error() . "<BR>"); if (mysql_num_rows($result)) { $emailInfo = mysql_fetch_assoc($result); foreach ($data as $key => $item) { $emailInfo['et_htmlformat'] = str_replace("[" . $key . "]", $item, stripslashes($emailInfo['et_htmlformat'])); $emailInfo['et_textformat'] = str_replace("[" . $key . "]", $item, stripslashes($emailInfo['et_textformat'])); $emailInfo['et_subject'] = str_replace("[" . $key . "]", $item, stripslashes($emailInfo['et_subject'])); } $mail = new PHPMailer(); $mail->From = $emailInfo['et_from']; $mail->FromName = $emailInfo['et_from_title']; $mail->Subject = $emailInfo['et_subject']; $mail->Host = "smtp.etelegate.com"; $mail->Mailer = "smtp"; // HTML body $body = $emailInfo['et_htmlformat']; // Plain text body (for mail clients that cannot read HTML) $text_body = $emailInfo['et_textformat']; $mail->Body = $body; $mail->AltBody = $text_body; $mail->AddAddress($data["email"], $data["full_name"]); if (!$mail->Send()) { echo "There has been a mail error sending to " . $row["email"] . "<br>"; } // Clear all addresses and attachments for next loop $mail->ClearAddresses(); $mail->ClearAttachments(); } else { die('Error: Email Template Not Found'); } }
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; }
/** * Send the current message to the current list of users. */ protected function sendToList() { $this->sentCount = 0; foreach ($this->users as $user) { if ($this->verbose && $this->sentCount % 100 == 0) { set_time_limit(60); echo '. '; } // Send message. $this->to($user['email'], $user['first'] . ' ' . $user['last']); $from = !empty($user['from']) ? $user['from'] : $this->from; $from_name = !empty($user['from_name']) ? $user['from_name'] : $this->fromName; $this->from($from, $from_name); $this->message->setUser(new User($user)); $this->message->setDefaultVars(); $this->subject($this->message->getSubject()); $this->message($this->message->getMessage()); if ($this->sendMessage()) { $this->sentCount++; } $this->mailer->ClearAddresses(); Tracker::trackEvent('Email Sent', $this->message->id, !empty($user['user_id']) ? $user['user_id'] : 0); } echo "\n\n"; }
public function send() { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->SMTPDebug = true; // enables SMTP debug information (for testing) $mail->SMTPAuth = true; // enable SMTP authentication $body = $this->body ? $this->body : NULL; $title = $this->title ? $this->title : NULL; $to = $this->email_to ? $this->email_to : NULL; $mail->SMTPSecure = 'tls'; // sets the prefix to the servier $mail->Host = 'smtp.dynect.net'; // sets GMAIL as the SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL server $mail->Username = '******'; // GMAIL username $mail->Password = '******'; // GMAIL password //$mail->SetFrom('*****@*****.**'); $mail->SetFrom('*****@*****.**', 'YeahMobi Team'); //PHP Mailer要求发送的From 与 mail account为同一主机名 $mail->ClearReplyTos(); $mail->ClearAddresses(); $mail->AddReplyTo('*****@*****.**', 'YeahMobi Team'); $mail->Subject = "=?utf-8?B?" . base64_encode($title) . "?="; //$mail->AltBody = $this->_contentReplace($v['title'], $v); // optional, comment out and test $mail->MsgHTML($body); $mail->AddAddress($to); $mail->Send(); }
public static function sendEmail($To, $Subject, $Body) { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->From = '*****@*****.**'; $mail->Sender = '*****@*****.**'; $mail->FromName = 'W&S Group'; $mail->SMTPSecure = "tls"; $mail->Host = 'smtp-mail.outlook.com'; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->Port = '587'; $mail->WordWrap = 500; $mail->IsHTML(true); $mail->Subject = $Subject; $mail->Body = $Body; $mail->AltBody = 'Xin chào'; $mail->AddAddress($To); if ($mail->Send()) { return true; } else { return false; } $mail->ClearAddresses(); $mail->ClearAttachments(); }
function email($email, $username, $body, $Subject) { // echo $body_text; $mail = new PHPMailer(); $mail->isSMTP(); $mail->Host = "ssl://smtp.gmail.com"; $mail->SingleTo = true; $mail->SMTPSecure = 'ssl'; $mail->Port = 465; $mail->SMTPAuth = true; $mail->Username = '******'; $mail->Password = '******'; $mail->From = '*****@*****.**'; $mail->FromName = 'Tarboz.com Adminstration'; $mail->addAddress($email, $username); $mail->addReplyTo('*****@*****.**', 'myInformation'); $mail->WordWrap = 50; $mail->isHTML(true); $mail->Subject = $Subject; $mail->Body = $body; //if Email was not sent it should return a true bool to the user if ($mail->send()) { $mail->ClearAddresses(); return true; } //successfully sent, then it should sent a true bool return false; }
/** * Cronjob function to end a cronjob in a critical condition * but not without sending a notification mail to the admin * * @param string $message * @param string $subject * * @return void */ function dieWithMail($message, $subject = "[froxlor] Cronjob error") { if (Settings::Get('system.send_cron_errors') == '1') { $_mail = new PHPMailer(true); $_mail->CharSet = "UTF-8"; if (PHPMailer::ValidateAddress(Settings::Get('panel.adminmail')) !== false) { // set return-to address and custom sender-name, see #76 $_mail->SetFrom(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname')); if (Settings::Get('panel.adminmail_return') != '') { $_mail->AddReplyTo(Settings::Get('panel.adminmail_return'), Settings::Get('panel.adminmail_defname')); } } $_mailerror = false; try { $_mail->Subject = $subject; $_mail->AltBody = $message; $_mail->MsgHTML(nl2br($message)); $_mail->AddAddress(Settings::Get('panel.adminmail'), Settings::Get('panel.adminmail_defname')); $_mail->Send(); } catch (phpmailerException $e) { $mailerr_msg = $e->errorMessage(); $_mailerror = true; } catch (Exception $e) { $mailerr_msg = $e->getMessage(); $_mailerror = true; } $_mail->ClearAddresses(); if ($_mailerror) { echo 'Error sending mail: ' . $mailerr_msg . "\n"; } } die($message); }
function sendMail($to, $subject, $message, $fromAddress = '', $fromUserName = '', $toName = '', $bcc = '', $upload_dir = '', $filename = '') { try { $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "sm4.siteground.biz"; $mail->Port = 2525; $mail->SMTPAuth = true; $mail->SMTPDebug = 1; // enables SMTP debug information (for testing) // Enable SMTP authentication $mail->Username = '******'; // SMTP username $mail->Password = '******'; // SMTP password $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 = "Video Collections"; } $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; } } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } }
/** * author:10xjzheng * 发生邮件,服务器用smtp.163.com,可以在$mail->Host改配置 * @param companyEmail string 公司邮箱/发生人邮箱 * @param password string 邮箱密码 * @param companyName string 公司名称 * @param receiveEmail string 收件人邮箱 * @param receiveUser string 收件人用户名 * @param subject string 主题 * @param bodyurl string 邮件内容 * @return res string 成功或失败 */ function sendEmail($companyEmail, $password, $companyName, $receiveEmail, $receiveUser, $subject, $bodyurl) { Vendor('PHPMailer.classphpmailer'); $verify = explode("@", $companyEmail); $mail = new PHPMailer(); $mail->SMTPDebug = false; $mail->IsSMTP(); // send via SMTP $mail->Host = "smtp.163.com"; // SMTP servers $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = $verify[0]; // SMTP username 注意:普通邮件认证不需要加 @域名 这里是我的163邮箱 $mail->Password = $password; // SMTP password 在这里输入邮箱的密码 $mail->From = $companyEmail; // 发件人邮箱 $mail->FromName = $receiveUser; // 发件人 $mail->CharSet = "UTF-8"; // 这里指定字符集! 指定UTF-8后邮件的标题和发件人等等不会乱码,如果是GB2312标题会乱码 $mail->Encoding = "base64"; $mail->AddAddress($receiveEmail, $receiveUser); // 收件人邮箱和姓名 $mail->AddReplyTo($companyEmail, $companyName); $mail->IsHTML(true); // send as HTML // 邮件主题 $mail->Subject = $subject; // 邮件内容 $mail->Body = $bodyurl; $mail->AltBody = "text/html"; if (!$mail->Send()) { $mail->ClearAddresses(); $res = "邮件错误信息: " . $mail->ErrorInfo; return $res; } else { $mail->ClearAddresses(); $res = "发送成功"; return $res; } }
public function smtp($to, $subject, $body, $option = null) { if (is_array($option)) { if (array_key_exists('name', $option)) { $this->name = $option['name']; } if (array_key_exists('debug', $option)) { $this->debug = $option['debug']; } } $mail = new PHPMailer(true); try { $mail->IsSMTP(); // telling the class to use SMTP $mail->CharSet = 'UTF-8'; $mail->XMailer = ' '; $mail->IsHTML(true); //$mail->SMTPSecure = 'tls'; $mail->SMTPDebug = $this->debug; // enables SMTP debug information (for testing) // 1 = errors and messages // 2 = messages only $mail->Host = $this->host; // sets the SMTP server $mail->Port = 25; // set the SMTP port for the GMAIL server $mail->SMTPAuth = false; // enable SMTP authentication $mail->Username = $this->username; // SMTP account username $mail->Password = $this->password; // SMTP account password $mail->SetFrom($this->from, 'Webmaster'); $mail->AddReplyTo($this->replyto, 'Webmaster'); $mail->Subject = $subject; //$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test //$body = eregi_replace("[\]",'',$body); $mail->MsgHTML($body); $mail->ClearAddresses(); $mail->AddAddress($to, $this->name); //$mail->AddAttachment("images/phpmailer.gif"); // attachment //$mail->AddAttachment("images/phpmailer_mini.gif"); // attachment if (!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } } catch (phpmailerException $e) { echo $e->errorMessage(); //Pretty error messages from PHPMailer } catch (Exception $e) { echo $e->getMessage(); //Boring error messages from anything else! } finally { $mail->smtpClose(); } }
function sendMail($to, $subject, $message, $fromAddress = '', $fromUserName = '', $toName = '', $bcc = '', $upload_dir = '', $filename = '') { $mail = new PHPMailer(); $mail->IsSMTP(); // send via SMTP $mail->Host = "smtp.gmail.com"; // SMTP servers $mail->SMTPAuth = true; // enable SMTP authentication $mail->SMTPSecure = "ssl"; // use ssl //$mail->Host = "mail.vivateachers.org"; // GMAIL's SMTP server $mail->Port = 465; // SMTP port used by GMAIL server $mail->IsHTML(true); // [optional] send as HTML $mail->Username = "******"; // SMTP username $mail->Password = "******"; // SMTP password $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 = "MediCart"; } $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; } }
public function smtp() { global $dbh, $postvar, $getvar, $instance; $body = eregi_replace("[\\]", '', $body); $users_data = $dbh->select("users", array("email", "=", $instance->email['to']), 0, "1"); $to_name = $users_data['firstname'] . " " . $users_data['lastname']; if ($to_name == " ") { $staff_data = $dbh->select("staff", array("email", "=", $instance->email['to']), 0, "1"); $to_name = $staff_data['name']; } if (!class_exists("PHPMailer")) { include INC . "/smtp/class_phpmailer.php"; } $mail = new PHPMailer(); $mail->IsSMTP(); // telling the class to use SMTP $mail->SMTPAuth = true; // enable SMTP authentication (Log in with credentials to send) $mail->SMTPKeepAlive = true; // SMTP connection will not close after each email sent $mail->Host = $instance->details['smtp_host']; // sets the SMTP server $mail->Port = $dbh->config('smtp_port'); // set the SMTP port for the SMTP server $mail->Username = $instance->details['smtp_user']; // SMTP account username $mail->Password = $instance->details['smtp_password']; // SMTP account password $mail->SetFrom($instance->details['from'], $dbh->config('name')); $mail->AddReplyTo($instance->details['from'], $dbh->config('name')); $mail->Subject = $instance->email['subject']; $mail->MsgHTML($instance->email['content']); $mail->AddAddress($instance->email['to'], $to_name); if (!$mail->Send()) { $response = "Mailer Error (" . $instance->email['to'] . ') ' . $mail->ErrorInfo . "\n"; main::thtlog("SMTP Error", $response, main::userid()); $mail->ClearAddresses(); return false; } $mail->ClearAddresses(); return true; }
/** * Test address escaping */ function test_AddressEscaping() { $this->Mail->Subject .= ': Address escaping'; $this->Mail->ClearAddresses(); $this->Mail->AddAddress('*****@*****.**', 'Tim "The Book" O\'Reilly'); $this->Mail->Body = 'Test correct escaping of quotes in addresses.'; $this->BuildBody(); $this->Mail->PreSend(); $b = $this->Mail->GetSentMIMEMessage(); $this->assertTrue(strpos($b, 'To: "Tim \\"The Book\\" O\'Reilly" <*****@*****.**>') !== false); }
function emailBlast($from, $fromname, $subject, $message, $emails, $bouncereturn, $debug = 0) { $_SMTPHOST = 'www.startuplist.sg'; $_SMTPUSER = '******'; $_SMTPPASS = '******'; $mail = new PHPMailer(); $mail->IsSMTP(); // set mailer to use SMTP //$mail->IsQmail(); $mail->Host = $_SMTPHOST; // specify main and backup server $mail->SMTPAuth = true; // turn on SMTP authentication $mail->Username = $_SMTPUSER; // SMTP username $mail->Password = $_SMTPPASS; // SMTP password $mail->Sender = $bouncereturn; $mail->From = $from; $mail->FromName = $fromname; if ($debug) { echo "From: {$fromname} <", $from, "><br>"; echo "Reply-To: ", $from, "<br>"; echo "Return Path: ", $bouncereturn, "<br>"; } $t = count($emails); for ($i = 0; $i < $t; $i++) { //print_r($emails[$i]); //$mail->AddAddress("*****@*****.**", "Josh Adams"); //$mail->AddReplyTo("*****@*****.**", "Josh Adams"); $mail->AddAddress($emails[$i]['email'], $emails[$i]['name']); $mail->AddReplyTo($from, $fromname); //$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 //western european encoding //$mail->Subject = "=?iso-8859-1?q?".$subject."?="; //$mail->Subject = "=?utf-8?q?".$this->subject."?="; $mail->Subject = $subject; $emailtext = $message; $mail->Body = $emailtext; $mail->AltBody = strip_tags($emailtext); if ($debug) { echo "Sending to <b>" . $emails[$i]['email'] . "</b> ... ", $mail->Send(), "<br>"; echo $mail->ErrorInfo; } else { $mail->Send(); } $mail->ClearAddresses(); } }
public function Mail($addresses, $content, $isHtml = true, $attachment = array()) { $mail = new PHPMailer(); if (isset($content['body']) && $content['body'] != '') { $mail->Body = trim($content['body']); } if (isset($content['altbody']) && $content['altbody'] != '') { $mail->AltBody = $content['altbody']; } else { if ($isHtml) { $mail->IsHTML(true); } $mail->AltBody = ''; } if (isset($content['subject']) && $content['subject'] != '') { $mail->Subject = $content['subject']; } if (isset($content['from']) && $content['from'] != '') { $mail->From = $content['from']; $mail->Sender = $content['from']; } if (isset($content['fromName']) && $content['fromName'] != '') { $mail->FromName = $content['fromName']; } if (!empty($attachment)) { !isset($attachment['path']) && ($attachment['path'] = null); !isset($attachment['name']) && ($attachment['name'] = null); !isset($attachment['encoding']) && ($attachment['encoding'] = 'base64'); !isset($attachment['type']) && ($attachment['type'] = 'application/octet-stream'); $mail->AddAttachment($attachment['path'], $attachment['name'], $attachment['encoding'], $attachment['type']); } $sendFailed = false; if ($addresses) { foreach ($addresses as $address) { $mail->AddAddress($address['email'], $address['name']); } if (!$mail->Send()) { $sendFailed = true; RDD::Log('RDM_Mail: In PHPMailer an error occured: ' . $mail->ErrorInfo, ERROR); } $mail->ClearAddresses(); } else { RDD::Log('RDM_Mail: No mail addresses passed to method Mail()', ERROR); $sendFailed = true; } return !$sendFailed; }
/** * Test addressing */ function test_Addressing() { $this->assertFalse($this->Mail->AddAddress('*****@*****.**'), 'Invalid address accepted'); $this->assertTrue($this->Mail->AddAddress('*****@*****.**'), 'Addressing failed'); $this->assertFalse($this->Mail->AddAddress('*****@*****.**'), 'Duplicate addressing failed'); $this->assertTrue($this->Mail->AddCC('*****@*****.**'), 'CC addressing failed'); $this->assertFalse($this->Mail->AddCC('*****@*****.**'), 'CC duplicate addressing failed'); $this->assertFalse($this->Mail->AddCC('*****@*****.**'), 'CC duplicate addressing failed (2)'); $this->assertTrue($this->Mail->AddBCC('*****@*****.**'), 'BCC addressing failed'); $this->assertFalse($this->Mail->AddBCC('*****@*****.**'), 'BCC duplicate addressing failed'); $this->assertFalse($this->Mail->AddBCC('*****@*****.**'), 'BCC duplicate addressing failed (2)'); $this->assertTrue($this->Mail->AddReplyTo('*****@*****.**'), 'Replyto Addressing failed'); $this->assertFalse($this->Mail->AddReplyTo('*****@*****.**'), 'Invalid Replyto address accepted'); $this->Mail->ClearAddresses(); $this->Mail->ClearCCs(); $this->Mail->ClearBCCs(); $this->Mail->ClearReplyTos(); }
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; } }
function send($address_to, $subject, $htmlcontent, $plaincontent, $attachment) { global $admin_name, $admin_email; $PHPMailer = new PHPMailer(); $PHPMailer->From = $admin_email; $PHPMailer->FromName = $admin_name; $PHPMailer->ClearAllRecipients(); $PHPMailer->AddAddress($address_to); $PHPMailer->Subject = $subject; $PHPMailer->Body = $htmlcontent; $PHPMailer->AltBody = $plaincontent; $PHPMailer->IsHTML(true); while (list($k, $v) = each($attachment)) { $PHPMailer->AddAttachment($v['file'], $v['nickname']); } $status = @$PHPMailer->Send(); $PHPMailer->ClearAddresses(); $PHPMailer->ClearAttachments(); return $status; }
/** * Отправка на почту * * @param string $subject * @param string $to * @param string $message * * @return bool */ protected function send($to, $subject, $message) { if ($this->layout) { $message = app()->controller->renderPartial($this->layout, array('content' => $message), TRUE); } if (!$this->PHPMailer instanceof PHPMailer) { return FALSE; } $this->PHPMailer->addAddress(trim($to)); $this->PHPMailer->Subject = trim($subject); $this->PHPMailer->Body = $message; $this->PHPMailer->AltBody = strip_tags($message); if (!$this->PHPMailer->send()) { Yii::log($this->PHPMailer->ErrorInfo, CLogger::LEVEL_ERROR, 'Notify'); return FALSE; } // Cleared $this->PHPMailer->ClearAddresses(); $this->PHPMailer->ClearAttachments(); return TRUE; }
public function actionSend() { $config = Setting::get('email'); $mail = new PHPMailer(); if ($config['transport'] == "smtp") { $mail->IsSMTP(); $mail->SMTPDebug = 3; } $mail->Host = $config['host']; $mail->Port = $config['port']; if ($config['username'] != '') { $mail->SMTPAuth = true; $mail->Username = $config['username']; if ($config['password']) { $mail->Password = $config['password']; } } $mail->SetFrom($config['from']); $mail->SMTPOptions = array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false, 'allow_self_signed' => true)); $mails = $this->params['mails']; if (is_array($mails)) { foreach ($mails as $m) { $mail->Subject = $m['subject']; $mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; $mail->MsgHTML($m['body']); $mail->IsHTML(true); $mail->AddAddress($m['to']); if (!$mail->Send()) { $this->log("Failed to send email to: " . $m['to']); } $mail->ClearAddresses(); } } else { echo " "; echo " ######## ERROR RUNNING EMAIL SERVICE #########"; echo " ### You should run this from Email::send() ###"; echo " ##############################################"; echo " "; } }
public function SendEmail($email_address_array, $from_email, $from_name, $email_data, $subject, $template, &$send_message) { global $smarty; $send_result = 0; $send_message = ''; if (is_array($email_address_array) && sizeof($email_address_array) > 0 && '' != trim($from_email) && '' != trim($from_name) && '' != trim($subject) && '' != $template) { try { $mail = new PHPMailer(true); $mail->IsSMTP(true); $mail->SMTPDebug = false; $mail->IsHTML(true); $mail->Host = Configurator::getInstance()->getSettings("phpmailer_smtp"); $mail->ClearAddresses(); for ($x = 0; $x < sizeof($email_address_array); $x++) { $mail->AddAddress(trim($email_address_array[$x])); } $smarty->assign('site_url', Configurator::getInstance()->getSettings("site_url")); $smarty->assign('email_data', $email_data); $mail->From = $from_email; $mail->FromName = $from_name; $mail->Subject = $subject; $mail->Body = $smarty->fetch($template); // echo $smarty->fetch( $template ); //exit(); if (!$mail->Send()) { } else { $send_result = 1; } } catch (phpmailerException $e) { $send_message = $e->errorMessage(); } catch (Exception $e) { $send_message = $e->getMessage(); } } else { $send_message = 'Data missing'; } echo $send_message; exit; return $send_result; }
function smtpmail($to, $subject, $content, $attach = false) { require_once 'config_app.php'; require_once 'phpmailer/class.phpmailer.php'; $mail = new PHPMailer(true); $mail->IsSMTP(); $mail->Host = $__smtp['host']; $mail->SMTPDebug = $__smtp['debug']; $mail->SMTPAuth = $__smtp['auth']; $mail->Host = $__smtp['host']; $mail->Port = $__smtp['port']; $mail->Username = $__smtp['username']; $mail->Password = $__smtp['password']; $mail->SetFrom($__smtp['addreply'], 'Mashkov Andrey'); $mail->AddReplyTo($__smtp['addreply'], $__smtp['username']); $mail->AddAddress($to); $mail->Subject = htmlspecialchars($subject); $mail->CharSet = 'utf8'; $mail->MsgHTML($content); if ($attach) { $mail->AddAttachment($attach); } if (!$mail->Send()) { $returner = "errorSend"; } else { $returner = "okSend"; } $mail->ClearAddresses(); $mail->ClearAttachments(); $mail->IsHTML(true); return $returner; }
function Notify($nletter, $nsubject, $nsignature) { require "phpmailer/class.phpmailer.php"; list($subscribers, $mails) = Populate(); SaveNewsLetter($nletter, $nsubject, $nsignature); //Log in and sender info $user = "******"; $pass = "******"; $from = "*****@*****.**"; $fname = "Greek Nature Adventure"; $k = 0; //Subject and message $subject = $nsubject; $msg = "\n\n\n" . $nletter . "\n\n" . $nsignature; //PHPMailer initialize $mail = new PHPMailer(); $mail->IsSMTP(); $mail->CharSet = 'UTF-8'; $mail->SetFrom($from, $fname); $mail->Host = "smtp.gmail.com"; $mail->SMTPAuth = true; $mail->Port = 587; $mail->Username = $user; $mail->Password = $pass; $mail->SMTPSecure = 'tls'; $mail->WordWrap = 75; $mail->Subject = $subject; $count = count($subscribers); while ($k < $count) { $greeting = "Hello " . $subscribers[$k] . " ! These are the latest news regarding our movie: "; $mail->Body = $greeting . "\n" . $msg; $mail->IsHTML = TRUE; $mail->AddAddress($mails[$k], $subscribers[$k]); $mail->send(); $mail->ClearAddresses(); $k++; } }
function dbem_send_mail($subject = "no title", $body = "No message specified", $receiver = '') { global $smtpsettings, $phpmailer, $cformsSettings; if (file_exists(dirname(__FILE__) . '/class.phpmailer.php') && !class_exists('PHPMailer')) { require_once dirname(__FILE__) . '/class.phpmailer.php'; require_once dirname(__FILE__) . '/class.smtp.php'; } $mail = new PHPMailer(); $mail->ClearAllRecipients(); $mail->ClearAddresses(); $mail->ClearAttachments(); $mail->CharSet = 'utf-8'; $mail->SetLanguage('en', dirname(__FILE__) . '/'); $mail->PluginDir = dirname(__FILE__) . '/'; get_option('dbem_rsvp_mail_send_method') == 'qmail' ? $mail->IsQmail() : ($mail->Mailer = get_option('dbem_rsvp_mail_send_method')); $mail->Host = get_option('dbem_smtp_host'); $mail->port = get_option('dbem_rsvp_mail_port'); if (get_option('dbem_rsvp_mail_SMTPAuth') == '1') { $mail->SMTPAuth = TRUE; } $mail->Username = get_option('dbem_smtp_username'); $mail->Password = get_option('dbem_smtp_password'); $mail->From = get_option('dbem_mail_sender_address'); //$mail->SMTPDebug = true; $mail->FromName = get_option('dbem_mail_sender_name'); // This is the from name in the email, you can put anything you like here $mail->Body = $body; $mail->Subject = $subject; $mail->AddAddress($receiver); if (!$mail->Send()) { echo "Message was not sent<br/ >"; echo "Mailer Error: " . $mail->ErrorInfo; // print_r($mailer); } else { // echo "Message has been sent"; } }
public function startFollow() { $filename = APP_DIR . 'cron/block.php'; $new_array = array(); $follow_price = $this->model->follow_price()->joined(true)->order("pos ASC")->getByActive(1); foreach ($follow_price as $key => $item) { $email = strtolower(trim($item['email'])); $new_array[$email][] = $item; } foreach ($new_array as $key => $item) { foreach ($item as $k => $v) { $new_array[$key][$k]['new_price'] = $v['product']['price']; if ($v['old_price'] <= $v['product']['price']) { unset($new_array[$key][$k]); } else { $this->database->update('follow_price', array('old_price' => $v['new_price'], 'procent' => $v['old_price'] - $v['new_price']), array('id' => $v['id'])); } } } foreach ($new_array as $key => $item) { if (isset($item) && is_array($item) && !empty($item)) { $data = new Dwoo_Data(); $data->assign('products', $item); $message = $this->dwoo->get("email/follow-mail.php", $data); $mail = new PHPMailer(true); $mail->From = "*****@*****.**"; $mail->FromName = "Interline"; $mail->CharSet = "utf-8"; $mail->Subject = "Скидка на товары"; $mail->IsHTML(true); $mail->MsgHTML($message); $mail->AddAddress(trim($key)); $mail->Send(); $mail->ClearAddresses(); } } }
function sendMail($emailToArr, $tema = "", $nota = "") { global $i; $hoy = date("Y-m-d H:i:s"); $mail = new PHPMailer(); $mail->Priority = 0; $mail->PluginDir = "../include/"; $mail->Mailer = "smtp"; $mail->Host = "opemantra.com.mx"; $mail->Port = 26; $mail->SMTPAuth = true; $mail->Username = "******"; $mail->Password = "******"; $mail->From = "*****@*****.**"; $mail->FromName = "Robot-Opemantra"; $mail->Timeout = 15; $mail->Body = "\n <center>\n <font size=5>TMA Transportes Maleja S.A. de C.V.</font><br> \n <font size=3 color=#B30000>http://www.transportesmaleja.com.mx</font><br>\n <br>\n <font size=3 color=red>.:: NOTIFICACION DE SISTEMA ::.</font><hr></center>\n <P>\n TEMA : <b>{$tema}</b><br> \n FECHA : {$hoy}\n <BR>\n {$nota}<br> \n <br>\n <br>\n "; $mail->AltBody = "\n NOTIFICACION DEL SISTEMA WEB \n\n TEMA : {$tema} \n\n {$nota} \n "; $mail->ClearAddresses(); //$emailToArr[] ="*****@*****.**"; foreach ($emailToArr as $emailTo) { if (!empty($emailTo)) { $mail->AddAddress($emailTo); } } // Copia Ciega //$mail->AddBCC("nestor@.com"); $mail->Subject = "[www.transportesmaleja.com.mx] Notificación de Sistema"; // Incluir Attach. //$mail->AddAttachment("../files/demo.txt","demo.txt"); $exito = $mail->Send(); if (!$exito) { echo "[ <font color=red><b>Problema de envio</b></font> ] {$emailTo} -> {$valor}" . $mail->ErrorInfo . "<br>"; } else { echo "[ <font color=green><b>Enviado</b></font> ] <br>"; } }