本文整理汇总了PHP中PHPMailer::clearAddresses方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::clearAddresses方法的具体用法?PHP PHPMailer::clearAddresses怎么用?PHP PHPMailer::clearAddresses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::clearAddresses方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send
/**
* @param bool $immediately
* @return bool
* @throws \phpmailerException
*/
public function send($immediately = true)
{
$salida = $this->mail->Send();
$this->mail->clearAddresses();
$this->mail->clearAttachments();
return $salida;
}
示例2: order
public static function order($name, $email = '', $phone = '', $address = '', $comment = '', $adminNotifyTplID = 'admin_purchase_notify', $customerNotifyTplID = 'user_purchase_notify')
{
global $db;
$user = \cf\User::getLoggedIn();
$productList = '';
$products = \cf\api\cart\getList();
if (!array_key_exists('contents', $products) || !count($products['contents'])) {
return false;
}
$tpl = new MailTemplate('order');
execQuery("\n\t\t\tINSERT INTO cf_orders (created,customer_name, customer_email, customer_phone, customer_address, customer_comments, comments)\n\t\t\tVALUES(NOW(),:name, :email, :phone, :address, :comments, :contents)", array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comments' => $comment, 'contents' => $tpl->parseBody(array('cart' => $products))));
$orderId = $db->lastInsertId();
$msgParams = array('name' => $name, 'email' => $email, 'phone' => $phone, 'address' => $address, 'comment' => $comment, 'order' => $orderId, 'total' => $products['total'], 'products' => $products['contents']);
\cf\api\cart\clear();
$mail = new \PHPMailer();
$mail->CharSet = 'UTF-8';
if ($adminNotifyTplID) {
$tpl = new MailTemplate($adminNotifyTplID);
$mail->Subject = $tpl->parseSubject($msgParams);
$mail->MsgHTML($tpl->parseBody($msgParams));
foreach ($tpl->recipients() as $address) {
$mail->addAddress($address);
}
$mail->Send();
}
$mail->clearAddresses();
if ($customerNotifyTplID && $email) {
$tpl = new MailTemplate($customerNotifyTplID);
$mail->Subject = $tpl->parseSubject($msgParams);
$mail->MsgHTML($tpl->parseBody($msgParams));
$mail->addAddress($email);
$mail->Send();
}
return $orderId;
}
示例3: actionAdd
public function actionAdd()
{
if (!isset($_POST['NewsHeader']) || !isset($_POST['NewsPreview']) || !isset($_POST['NewsText']) || !isset($_POST['NewsTags'])) {
header("HTTP/1.0 404 Not Found");
throw new E404Exception('Required params can not be null');
}
$NewsRecord = new News();
$NewsRecord->NewsHeader = $_POST['NewsHeader'];
$NewsRecord->NewsPreview = $_POST['NewsPreview'];
$NewsRecord->NewsText = $_POST['NewsText'];
$NewsRecord->NewsTags = $_POST['NewsTags'];
$NewsRecord->publishdate = 'NOW()';
$NewsRecord->insert();
$mail = new \PHPMailer();
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->Username = 'shilov.kirill.transas@gmail.com';
$mail->Password = 'qwertyASDFGHzxcvbn';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'ssl';
$mail->Port = '465';
$mail->addAddress('shilov.kirill.transas@gmail.com');
$mail->Body = 'Created news';
$mail->AltBody = 'Body created';
$mail->send();
$mail->clearAddresses();
header('Location: ./index.php');
}
示例4: testAddressEscaping
/**
* Test address escaping.
*/
public function testAddressEscaping()
{
$this->Mail->Subject .= ': Address escaping';
$this->Mail->clearAddresses();
$this->Mail->addAddress('foo@example.com', '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" <foo@example.com>') !== false);
}
示例5: send
function send($from = "", $fromname = "", $sender = false)
{
// function send($from="",$fromname=""){
if ($this->email != "") {
$contentType = $this->contentType;
$email = $this->email;
$subject = $this->subject;
$body = $this->body;
$mail = new PHPMailer();
if ($from != "") {
$mail->From = $from;
} else {
$mail->From = CFG::FROM;
}
if ($fromname != "") {
$mail->FromName = $fromname;
} else {
$mail->FromName = CFG::FROMNAME;
}
$mail->ContentType = $contentType;
$mail->CharSet = 'UTF-8';
if ($sender === false) {
$sender = $mail->From;
}
$mail->Sender = $sender;
$mail->Subject = $subject;
$mail->Body = $body;
if ($altBody != '') {
$mail->AltBody = $altbody;
}
$mail->clearAddresses();
if (is_array($email)) {
foreach ($email as $em) {
$mail->addAddress($em);
}
} else {
if (strpos($email, ',') !== false) {
$adds = explode(',', $email);
foreach ($adds as $em) {
$mail->addAddress($em);
}
} else {
$mail->addAddress($email);
}
}
if (!is_null($this->attachment)) {
$tmp = $mail->AddAttachment($this->attachment);
}
$mail->Send();
}
}
示例6: postmail
function postmail($to, $subject = "", $body = "")
{
//$to 表示收件人地址 $subject 表示邮件标题 $body表示邮件正文
//error_reporting(E_ALL);
//error_reporting(E_STRICT);
date_default_timezone_set("Asia/Shanghai");
//设定时区东八区
require_once APP . 'controller/class.phpmailer.php';
require_once APP . "controller/class.smtp.php";
$mail = new PHPMailer();
//new一个PHPMailer对象出来
//$body = preg_replace("[\]",'',$body); //对邮件内容进行必要的过滤
$mail->CharSet = "UTF-8";
//设定邮件编码,默认ISO-8859-1,如果发中文此项必须设置,否则乱码
$mail->IsSMTP();
// 设定使用SMTP服务
$mail->SMTPDebug = 0;
// 启用SMTP调试功能
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true;
// 启用 SMTP 验证功能
$mail->SMTPSecure = "tls";
// 安全协议
$mail->Host = "smtp.sina.com.cn";
// SMTP 服务器
$mail->Port = 25;
// SMTP服务器的端口号
$mail->WordWrap = 50;
$mail->Username = "thedc17@sina.com";
// SMTP服务器用户名
$mail->Password = "Hardware";
// SMTP服务器密码
$mail->SetFrom('thedc17@sina.com', '电子设计大赛官方邮箱');
$mail->AddReplyTo("thedc17@sina.com", "电子设计大赛官方邮箱");
$mail->Subject = $subject;
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!";
// optional, comment out and test
$mail->MsgHTML($body);
for ($i = 0; $i < count($to); ++$i) {
$mail->AddAddress($to[$i][0]);
$mail->Send();
$mail->clearAddresses();
}
}
示例7: sola_nl_ajax_send
//.........这里部分代码省略.........
$saved_send_method = get_option("sola_nl_send_method");
if ($saved_send_method == "1") {
$headers[] = 'From: ' . $sent_from_name . '<' . $sent_from . '>';
$headers[] = 'Content-type: text/html';
$headers[] = 'Reply-To: ' . $reply_name . '<' . $reply . '>';
} else {
if ($saved_send_method >= "2") {
$file = PLUGIN_URL . '/includes/phpmailer/PHPMailerAutoload.php';
require_once $file;
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
$port = get_option("sola_nl_port");
$encryption = get_option("sola_nl_encryption");
if ($encryption) {
$mail->SMTPSecure = $encryption;
}
$host = get_option("sola_nl_host");
$mail->Host = $host;
$mail->Username = get_option("sola_nl_username");
$mail->Password = get_option("sola_nl_password");
$mail->Port = $port;
$mail->AddReplyTo($reply, $reply_name);
$mail->SetFrom($sent_from, $sent_from_name);
$mail->Subject = $camp->subject;
$mail->SMTPDebug = 0;
}
}
if ($subscribers) {
foreach ($subscribers as $subscriber) {
set_time_limit(600);
$sub_id = $subscriber['sub_id'];
$sub_email = $subscriber['sub_email'];
echo $sub_email;
$body = sola_nl_mail_body($camp->email, $sub_id, $camp->camp_id);
$sola_global_subid = $sub_id;
$sola_global_campid = $camp->camp_id;
$body = do_shortcode($body);
$body = sola_nl_replace_links($body, $sub_id, $camp->camp_id);
/* ------ */
//$check = sola_mail($camp_id ,$sub_email, $camp->subject, $body);
if ($saved_send_method == "1") {
if (wp_mail($sub_email, $camp->subject, $body, $headers)) {
$check = true;
} else {
if (!$debug) {
$check = array('error' => 'Error sending mail to' . $sub_email);
} else {
$check = array('error' => "Failed to send email to {$sub_email}... " . $GLOBALS['phpmailer']->ErrorInfo);
}
}
} else {
if ($saved_send_method >= "2") {
if (is_array($sub_email)) {
foreach ($sub_email as $address) {
$mail->AddAddress($address);
}
} else {
$mail->AddAddress($sub_email);
}
$mail->Body = $body;
$mail->IsHTML(true);
//echo "sending to $sub_email<br />";
if (!$mail->Send()) {
$check = array('error' => 'Error sending mail to ' . $sub_email);
} else {
$check = true;
}
}
}
if ($check === true) {
sola_update_camp_limit($camp_id);
$wpdb->update($sola_nl_camp_subs_tbl, array('status' => 1), array('camp_id' => $camp_id, 'sub_id' => $sub_id), array('%d'), array('%d', '%d'));
//echo "Email sent to $sub_email successfully <br />";
} else {
sola_return_error(new WP_Error('sola_error', __('Failed to send email to subscriber'), 'Could not send email to ' . $sub_email));
//echo "<p>Failed to send to ".$sub_email."</p>";
}
$mail->clearAddresses();
$mail->clearAttachments();
$end = (double) array_sum(explode(' ', microtime()));
echo "<br />processing time: " . sprintf("%.4f", $end - $debug_start) . " seconds<br />";
//$check = sola_nl_send_mail_via_cron($camp_id,$sub_id,$sub_email);
//if ( is_wp_error($check)) sola_return_error($check);
}
} else {
/* do nothing, reached limit */
}
if ($saved_send_method >= "2") {
$mail->smtpClose();
}
$end = (double) array_sum(explode(' ', microtime()));
echo "<br />processing time: " . sprintf("%.4f", $end - $debug_start) . " seconds<br />";
update_option("sola_currently_sending", "no");
sola_nl_done_sending_camp($camp_id);
} else {
echo "<br />nothing to send at this time<br />";
}
}
示例8: save_lead
//.........这里部分代码省略.........
width:90%;
margin:auto;
padding:2%;
border-radius:10px;
}
#submission_info table, #submission_info tr,#submission_info td {
margin:auto;
color:#000;
}
a {
//color:#FE3F44;
color:#303030;
}
#email_photo {
max-width:500px;
margin:1% 0 3% 0;
box-shadow:0px 0px 5px #303030;
}
#signature_block {
margin: 4% auto;
font-size:80%;
}
</style>
<body>
<img style="width:250px" src="http://freelabel.net/images/FREELABELLOGO.gif"><br>
<img style="width:250px" src="http://freelabel.net/images/flheadblack.png"><br>
<div id="para_text">
<h1>' . $email_subject . '</h1>
' . $email_body . "\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<hr>\n\t\t\t\t\t\t\t\t\t\t\t\t" . '<h2>LEAD INFORMATION:</h2>
<div id="submission_info">
<table>
<tr>
<td>COMMENTS:</td>
<td>' . $lead_name . '</td>
</tr>
<tr>
<td>PHONE:</td>
<td>' . $lead_phone . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>FOLLOW UP // ENTRY DATE:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $follow_up_date . " // " . $entry_date . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>TWITTER:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $lead_twitter . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>EMAIL:</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<td>" . $lead_email . "</td>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<br><br>\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div id='signature_block'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<u>FREELABEL Account Executive</u>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<br>c: (323) 601-8111<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\te: info@FREELABEL.net\n\n\n\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t<br>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\nFREELABEL.net\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t</body>";
$stafflist = array('notifications@freelabel.net', 'sales@freelabel.net', 'request.chiffon@gmail.com');
//foreach ($stafflist as $admin) {
include '../../../mailer/PHPMailerAutoload.php';
//Create a new PHPMailer instance
$mail = new PHPMailer();
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom('admin@freelabel.net', 'FL SALES');
//Set an alternative reply-to address
$mail->addReplyTo('admin@freelabel.net', 'Sales Administration');
//Set the subject line
$mail->Subject = $email_subject;
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
$mail->msgHTML($body_template);
//Replace the plain text body with one created manually
$mail->AltBody = $body_template;
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.png');
//send the message, check for errors
foreach ($stafflist as $admin) {
//This iterator syntax only works in PHP 5.4+
$mail->addAddress($admin, 'FREELABEL SUBMISSIONS');
if (!empty($row['photo'])) {
$mail->addStringAttachment($row['photo'], 'YourPhoto.jpg');
//Assumes the image data is stored in the DB
}
if (!$mail->send()) {
echo "Mailer Error (" . str_replace("@", "@", $admin) . ') ' . $mail->ErrorInfo . '<br />';
break;
//Abandon sending
} else {
echo "Message sent to: " . $admin . "!<br>";
//echo "<br><br><br><br>".$body_template.'<br><br>';
echo "Message sent to :" . $admin . ' (' . str_replace("@", "@", $admin) . ')<br />';
}
// Clear all addresses and attachments for next loop
$mail->clearAddresses();
$mail->clearAttachments();
}
echo "Entry Created Successfully! ";
echo "<script>\n\t\t\t\t\t\t\t\t\t\t\tfunction newDoc()\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\twindow.location.assign(\"http://freelabel.net/?ctrl=leads#add\")\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tnewDoc()\n\t\t\t\t\t\t\t\t\t\t\t</script>";
echo '<style>
html {
color:#fff;
background-color:#303030;
margin:10%;
font-size:300%;
font-family:sans-serif;
}
</style>';
echo "Your LEAD has been Saved. Please stay updated!<br><br>Your Lead: <p id='sub_label' >" . $lead_name . '<br>TWITTER: ';
echo $lead_twitter . " and you must follow up on: " . $follow_up_date . "</p><a href='http://freelabel.net/submit/#leads'>Return to Dashboard</a><br><br><br><br><br><br>";
} else {
echo "Error creating database entry: " . mysqli_error($con);
}
}
}
示例9: notify
/**
* Send an email notification to devs
* @param STRING $type The type of notification to send ('new', 'close', 'comment', or 'assign')
* @return INt Number of email actually sent
*/
public function notify($type)
{
global $LANG;
$iC = new Infos('t_config');
$iC->loadInfos('nom', 'enable_notify');
if ($iC->getInfos('value') == 0) {
return 0;
}
$iC->loadInfos('nom', 'project_name');
$project_name = $iC->getInfos('value');
$iC->loadInfos('nom', 'language');
$language = $iC->getInfos('value');
$mail = new PHPMailer(true);
$mail->isMail();
if ($language === 'Francais') {
$mail->setLanguage('fr', INSTALL_PATH . 'language/phpMailer/');
}
$mail->CharSet = 'UTF-8';
$mail->From = "admin@bughunter.net";
$mail->FromName = "Bughunter {$project_name}";
$mail->isHTML(true);
switch ($type) {
case "new":
$subject = $LANG['Notify_newBug_subject'];
$bodyTxt = $LANG['Notify_newBug_body'];
break;
case "close":
$subject = $LANG['Notify_killBug_subject'];
$bodyTxt = $LANG['Notify_killBug_body'];
break;
case "comment":
$subject = $LANG['Notify_comment_subject'];
$bodyTxt = $LANG['Notify_comment_body'];
break;
case "assign":
$subject = $LANG['Notify_assign_subject'];
$bodyTxt = $LANG['Notify_assign_body'];
break;
default:
throw new Exception("Notification type unknown.");
}
$bugData = $this->getBugData(true);
$subject = preg_replace('/\\{\\{BUG_ID\\}\\}/', $bugData['id'], $subject);
$mail->Subject = $subject;
$template = file_get_contents(INSTALL_PATH . 'mails/template.html');
$html = preg_replace('/\\{\\{SUBJECT\\}\\}/', $subject, $template);
$html = preg_replace('/\\{\\{BODY\\}\\}/', $bodyTxt, $html);
$html = preg_replace('/\\{\\{DATE\\}\\}/', date('Y-m-d'), $html);
$html = preg_replace('/\\{\\{PROJECT\\}\\}/', $project_name, $html);
$html = preg_replace('/\\{\\{URL_BH\\}\\}/', preg_replace('/\\/actions$/', '', get_url()), $html);
$html = preg_replace('/\\{\\{REPORTER\\}\\}/', $bugData['author'], $html);
$html = preg_replace('/\\{\\{BUG_ID\\}\\}/', $bugData['id'], $html);
$html = preg_replace('/\\{\\{BUG_TITLE\\}\\}/', $bugData['title'], $html);
$html = preg_replace('/\\{\\{BUG_DESCR\\}\\}/', $bugData['description'], $html);
$html = preg_replace('/\\{\\{BUG_LABEL\\}\\}/', $bugData['label']['name'], $html);
if ($type === "comment") {
$comm = end($bugData['comment']);
$html = preg_replace('/\\{\\{COMM_AUTHOR\\}\\}/', $comm['dev']['pseudo'], $html);
$html = preg_replace('/\\{\\{COMM_MESSAGE\\}\\}/', nl2br($comm['message']), $html);
}
$l = new Liste();
$l->addFiltre('id', '>', '0');
$l->addFiltre('notify', '=', '1');
$l->getListe('t_devs');
$devs = $l->simplifyList();
if (!$devs) {
return 0;
}
$countSent = 0;
foreach ($devs as $dev) {
if ($type === "assign" && $bugData['FK_dev_ID'] != $dev['id']) {
continue;
}
$mail->Body = $html;
$mail->addAddress($dev['mail']);
if ($mail->send()) {
$countSent++;
}
$mail->clearAddresses();
// file_put_contents(INSTALL_PATH.'data/debugMail_'.$dev['pseudo'].'.html', $html);
}
return $countSent;
}
示例10: initMailer
/**
* Initialisiert ein Objekt der Klasse PhpMailer und setzt die
* Authentifizierung des Systems ein.
* @param int $port pass a port number here
* @param string $security an empty string or 'tls' or 'ssl'
* @return \PHPMailer
* @throws Exception if PHPMailer throws an exception
*/
public static function initMailer($port = null, $security = null)
{
/** PhpMailer einbinden */
require_once realpath(ROOT_PATH) . '/external_scripts/phpmailer/class.phpmailer.php';
require_once realpath(ROOT_PATH) . "/external_scripts/phpmailer/class.smtp.php";
$mail = new PHPMailer();
// Vorformatierungen
$mail->setLanguage('de');
$mail->CharSet = 'utf-8';
$mail->clearAttachments();
$mail->clearAddresses();
if (defined('SMTP_HOST') && strlen(SMTP_HOST) > 0) {
// SMTP-Autorisierung
$mail->isSMTP();
$mail->Host = SMTP_HOST;
if (defined('DEBUG_MODUS') && DEBUG_MODUS > 0) {
$mail->SMTPDebug = 2;
}
if (!is_null($port)) {
$mail->Port = $port;
} elseif (defined('SMTP_PORT') && strlen(SMTP_PORT) > 0) {
$mail->Port = SMTP_PORT;
}
if (defined('SMTP_USER') && strlen(SMTP_USER) > 0 && defined('SMTP_PASSWORD') && strlen(SMTP_PASSWORD) > 0) {
$mail->SMTPAuth = true;
$mail->Username = SMTP_USER;
$mail->Password = SMTP_PASSWORD;
if (!is_null($security)) {
$mail->SMTPSecure = $security;
} elseif (defined("SMTP_SECURITY") && strlen(SMTP_SECURITY) > 0) {
$mail->SMTPSecure = SMTP_SECURITY;
}
} else {
$mail->SMTPAuth = false;
}
} else {
$mail->isSendmail();
}
return $mail;
}
示例11: send
public function send($isEach = false)
{
require_once $this->Module->getPath() . '/classes/phpmailer/class.phpmailer.php';
if (empty($this->to) == true || $this->subject == null || $this->content == null) {
return false;
}
if (empty($this->from) == true) {
$this->from = array('arzz@arzz.com', '알쯔닷컴');
}
$phpMailer = new PHPMailer();
$phpMailer->pluginDir = $this->Module->getPath() . '/classes/phpmailer';
$phpMailer->isHTML(true);
$phpMailer->Encoding = 'base64';
$phpMailer->CharSet = 'UTF-8';
if (count($this->from) == 2) {
$phpMailer->setFrom($this->from[0], '=?UTF-8?b?' . base64_encode($this->from[1]) . '?=');
} else {
$phpMailer->setFrom($this->from[0]);
}
if (count($this->replyTo) == 1) {
$phpMailer->addReplyTo($this->replyTo[0]);
} elseif (count($this->replyTo) == 2) {
$phpMailer->addReplyTo($this->replyTo[0], '=?UTF-8?b?' . base64_encode($this->replyTo[1]) . '?=');
}
if (count($this->cc) > 0) {
for ($i = 0, $loop = count($this->cc); $i < $loop; $i++) {
if (count($this->cc[$i]) == 2) {
$phpMailer->addBcc($this->cc[$i][0], '=?UTF-8?b?' . base64_encode($this->cc[$i][1]) . '?=');
} else {
$phpMailer->addBcc($this->cc[$i][0]);
}
}
}
if (count($this->bcc) > 0) {
for ($i = 0, $loop = count($this->bcc); $i < $loop; $i++) {
if (count($this->bcc[$i]) == 2) {
$phpMailer->addBcc($this->bcc[$i][0], '=?UTF-8?b?' . base64_encode($this->bcc[$i][1]) . '?=');
} else {
$phpMailer->addBcc($this->bcc[$i][0]);
}
}
}
$templet = '<div>{$content}</div>';
$phpMailer->Subject = '=?UTF-8?b?' . base64_encode($this->subject) . '?=';
$idx = $this->db()->insert($this->table->send, array('from' => empty($this->from[1]) == true ? $this->from[0] : $this->from[1] . ' <' . $this->from[0] . '>', 'subject' => $this->subject, 'content' => $this->content, 'search' => GetString($this->content, 'index'), 'receiver' => count($this->to), 'reg_date' => time()))->execute();
if ($isEach == true || count($this->to) == 1) {
for ($i = 0, $loop = count($this->to); $i < $loop; $i++) {
$receiverIdx = $this->db()->insert($this->table->receiver, array('parent' => $idx, 'to' => empty($this->to[$i][1]) == true ? $this->to[$i][0] : $this->to[$i][1] . ' <' . $this->to[$i][0] . '>', 'reg_date' => time()))->execute();
$phpMailer->clearAddresses();
if (count($this->to[$i]) == 2) {
$phpMailer->addAddress($this->to[$i][0], '=?UTF-8?b?' . base64_encode($this->to[$i][1]) . '?=');
} else {
$phpMailer->addAddress($this->to[$i][0]);
}
$phpMailer->Body = str_replace('{$content}', $this->content . '<img src="http://' . $_SERVER['HTTP_HOST'] . $this->IM->getProcessUrl('email', 'check', array('receiver' => $receiverIdx)) . '" style="width:1px; height:1px;" />', $templet);
$result = $phpMailer->send();
if ($result == true) {
$this->db()->update($this->table->receiver, array('status' => 'SUCCESS'))->where('idx', $receiverIdx)->execute();
} else {
$this->db()->update($this->table->receiver, array('status' => 'FAIL', 'result' => $result))->where('idx', $receiverIdx)->execute();
}
}
} else {
if (count($this->from) == 2) {
$phpMailer->addAddress($this->from[0], '=?UTF-8?b?' . base64_encode($this->from[1]) . '?=');
} else {
$phpMailer->addAddress($this->from[0]);
}
for ($i = 0, $loop = count($this->to); $i < $loop; $i++) {
if (count($this->to[$i]) == 2) {
$phpMailer->addBCC($this->to[$i][0], '=?UTF-8?b?' . base64_encode($this->to[$i][1]) . '?=');
} else {
$phpMailer->addBCC($this->to[$i][0]);
}
}
}
$this->reset();
return;
}
示例12: sendMail
public function sendMail()
{
$siteEmail = SITE_EMAIL;
$variableEngine = VariableEngine::getInstance();
$smtpServer = $variableEngine->getVariable('smtpServer');
if ($smtpServer === false) {
return false;
}
$smtpPort = $variableEngine->getVariable('smtpPort');
if ($smtpPort === false) {
return false;
}
$smtpUserName = $variableEngine->getVariable('smtpUserName');
if ($smtpUserName === false) {
return false;
}
$smtpPassword = $variableEngine->getVariable('smtpPassword');
if ($smtpPassword === false) {
return false;
}
$smtpUseEncryption = $variableEngine->getVariable('smtpUseEncryption');
if ($smtpUseEncryption === false) {
return false;
}
$smtpUseEncryption = $smtpUseEncryption->getValue();
if ($smtpUseEncryption === 'false') {
$encryption = "";
} else {
$encryption = "tls";
}
$toSend = new PHPMailer();
$toSend->isSMTP();
$toSend->Host = $smtpServer->getValue();
$toSend->SMTPAuth = true;
$toSend->Username = $smtpUserName->getValue();
$enc = new Encrypter();
$toSend->Password = $enc->decrypt($smtpPassword->getValue());
$toSend->SMTPSecure = $encryption;
$toSend->Port = intval($smtpPort->getValue());
$toSend->From = $siteEmail;
$toSend->FromName = $this->senderName;
$toSend->addReplyTo($this->senderEmail, $this->senderName);
$toSend->isHTML(true);
$toSend->Subject = $this->subject;
if ($this->isBulkMail) {
foreach ($this->recipients as $recipient) {
$toSend->addBCC($recipient);
}
$toSend->Body = $this->body;
$toSend->AltBody = strip_tags($this->body);
if (!$toSend->send()) {
$this->errors[] = $toSend->ErrorInfo;
return false;
}
return true;
}
$sent = true;
foreach ($this->recipients as $recipient) {
$body = $this->doReplacement($recipient);
$altBody = strip_tags($body);
$toSend->clearAddresses();
$toSend->addAddress($recipient);
$toSend->Body = $body;
$toSend->AltBody = $altBody;
if (!$toSend->send()) {
$this->errors = $toSend->ErrorInfo;
$sent = false;
}
}
return $sent;
}
示例13: sendSMTPMultiEmail
function sendSMTPMultiEmail($from_email, $from_name, $data_array)
{
//$this->sendMultiEmailCI($from_email,$from_name,$data_array);
require_once "PHPMailer/class.phpmailer.php";
try {
$mail = new PHPMailer(true);
$mail->IsSMTP();
// telling the class to use SMTP
$mail->SMTPDebug = 0;
// enables SMTP debug information (for testing)
if (ENVIRONMENT == 'development') {
$mail->SMTPAuth = true;
// enable SMTP authentication
$mail->SMTPSecure = "ssl";
// sets the prefix to the servier
$mail->Host = "smtp.gmail.com";
// sets GMAIL as the SMTP server
$mail->Port = 465;
$mail->Username = "auto.email.sender.gate2@gmail.com";
// SMTP server username
$mail->Password = "admine2#";
// SMTP server password
} else {
$mail->SMTPAuth = true;
// enable SMTP authentication
$mail->SMTPSecure = "ssl";
$mail->Host = "server1.juzonmail.com";
$mail->Port = 465;
$mail->Username = "juzon@juzon.com";
$mail->Password = "qwer7890";
}
//$mail->From = $from_email;
//$mail->FromName = "$from_name <$from_email>";//$from_name;
$mail->CharSet = "UTF-8";
$mail->AddReplyTo($from_email, $from_name);
$mail->SetFrom($from_email, $from_name);
foreach ($data_array as $k => $item) {
$to = $item['to_email'];
$mail->AddAddress($to, $item['to_subject']);
//$mail->AddCC($to);
$mail->Subject = $item['to_subject'];
debug($item['to_subject'], "subj.txt");
$body = $item['body'];
$mail->MsgHTML($body);
$mail->IsHTML(true);
// send as HTML
$mail->Send();
$mail->clearAddresses();
$mail->ClearAttachments();
}
return true;
//echo 'Message has been sent.';
} catch (phpmailerException $e) {
return false;
//echo $e->errorMessage();
}
}
示例14: PHPMailer
function send_email()
{
$mail = new PHPMailer();
$body = "Congratulation! <br> You have a new request to add him in your slack team. Please login to Slack Invitation App to respond on new request.";
$mail->isSMTP();
$mail->Host = 'email-smtp.us-east-1.amazonaws.com';
$mail->SMTPAuth = true;
$mail->SMTPKeepAlive = true;
// SMTP connection will not close after each email sent, reduces SMTP overhead
$mail->Port = 587;
$mail->Username = 'AKIAJSGXEMDO7XF263NA';
$mail->Password = 'ApRz3QVxkWwaEAKvBZnhEkBS6S9HGZXEylwp5SyHizW4';
$mail->setFrom('do-not-reply@bsf.io', 'Brainstorm Force');
$mail->Subject = "Slack Invitation Request";
$mail->msgHTML($body);
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$count = 0;
$sql = run_query("select * from `sia-options` where `option_name` = 'notification-emails'");
$result = fetch_data($sql);
$result = unserialize($result['option_value']);
for ($i = 0; $i < count($result); $i++) {
if (!empty($result['user' . $i])) {
if ($result['user' . $i][2] == 'on') {
$mail->addAddress($result['user' . $i][1], $result['user' . $i][0]);
if (!$mail->send()) {
echo "Mailer Error " . $mail->ErrorInfo . '<br />';
break;
//Abandon sending
} else {
$count++;
}
}
// Clear all addresses and attachments for next loop
$mail->clearAddresses();
$mail->clearAttachments();
}
}
echo "Message sent to " . $count . " member(s)";
}
示例15: check
//.........这里部分代码省略.........
continue;
}
$cities = array();
if ($alert->cities) {
$cities = array_map("trim", explode("\n", mb_strtolower($alert->cities)));
}
$filter = new \AdService\Filter(array("price_min" => $alert->price_min, "price_max" => $alert->price_max, "cities" => $cities, "price_strict" => (bool) $alert->price_strict, "categories" => $alert->getCategories(), "min_id" => $unique_ads ? $alert->last_id : 0));
$ads = $parser->process($content, $filter, parse_url($alert->url, PHP_URL_SCHEME));
$countAds = count($ads);
if ($countAds == 0) {
$storage->save($alert);
continue;
}
$siteConfig = \AdService\SiteConfigFactory::factory($alert->url);
$newAds = array();
$time_last_ad = (int) $alert->time_last_ad;
foreach ($ads as $ad) {
if ($time_last_ad < $ad->getDate()) {
$newAds[$ad->getId()] = (require DOCUMENT_ROOT . "/app/mail/views/mail-ad.phtml");
if ($alert->time_last_ad < $ad->getDate()) {
$alert->time_last_ad = $ad->getDate();
}
if ($unique_ads && $ad->getId() > $alert->last_id) {
$alert->last_id = $ad->getId();
}
}
}
if (!$newAds) {
$storage->save($alert);
continue;
}
$countAds = count($newAds);
$this->_logger->info($countAds . " annonce" . ($countAds > 1 ? "s" : "") . " trouvée" . ($countAds > 1 ? "s" : ""));
$this->_mailer->clearAddresses();
$error = false;
if ($alert->send_mail) {
try {
$emails = explode(",", $alert->email);
foreach ($emails as $email) {
$this->_mailer->addAddress(trim($email));
}
} catch (phpmailerException $e) {
$this->_logger->warn($e->getMessage());
$error = true;
}
if (!$error) {
if ($alert->group_ads) {
$newAdsCount = count($newAds);
$subject = "Alert " . $siteConfig->getOption("site_name") . " : " . $alert->title;
$message = '<h2>' . $newAdsCount . ' nouvelle' . ($newAdsCount > 1 ? 's' : '') . ' annonce' . ($newAdsCount > 1 ? 's' : '') . ' - ' . date("d/m/Y H:i", $currentTime) . '</h2>
<p>Lien de recherche: <a href="' . htmlspecialchars($alert->url, null, "UTF-8") . '">' . htmlspecialchars($alert->url, null, "UTF-8") . '</a></p>
<hr /><br />' . implode("<br /><hr /><br />", $newAds) . '<hr /><br />';
$this->_mailer->Subject = $subject;
$this->_mailer->Body = $message;
try {
$this->_mailer->send();
} catch (phpmailerException $e) {
$this->_logger->warn($e->getMessage());
}
} else {
$newAds = array_reverse($newAds, true);
foreach ($newAds as $id => $ad) {
$subject = ($alert->title ? $alert->title . " : " : "") . $ads[$id]->getTitle();
$message = '<h2>Nouvelle annonce - ' . date("d/m/Y H:i", $currentTime) . '</h2>
<p>Lien de recherche: <a href="' . htmlspecialchars($alert->url, null, "UTF-8") . '">' . htmlspecialchars($alert->url, null, "UTF-8") . '</a></p>
<hr /><br />' . $ad . '<hr /><br />';