本文整理汇总了PHP中PHPMailer::clearAllRecipients方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::clearAllRecipients方法的具体用法?PHP PHPMailer::clearAllRecipients怎么用?PHP PHPMailer::clearAllRecipients使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::clearAllRecipients方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testDuplicateIDNRemoved
/**
* Tests removal of duplicate recipients and reply-tos.
*/
public function testDuplicateIDNRemoved()
{
if (!$this->Mail->idnSupported()) {
$this->markTestSkipped('intl and/or mbstring extensions are not available');
}
$this->Mail->clearAllRecipients();
$this->Mail->clearReplyTos();
$this->Mail->CharSet = 'utf-8';
$this->assertTrue($this->Mail->addAddress('test@françois.ch'));
$this->assertFalse($this->Mail->addAddress('test@françois.ch'));
$this->assertTrue($this->Mail->addAddress('test@FRANÇOIS.CH'));
$this->assertFalse($this->Mail->addAddress('test@FRANÇOIS.CH'));
$this->assertTrue($this->Mail->addAddress('test@xn--franois-xxa.ch'));
$this->assertFalse($this->Mail->addAddress('test@xn--franois-xxa.ch'));
$this->assertFalse($this->Mail->addAddress('test@XN--FRANOIS-XXA.CH'));
$this->assertTrue($this->Mail->addReplyTo('test+replyto@françois.ch'));
$this->assertFalse($this->Mail->addReplyTo('test+replyto@françois.ch'));
$this->assertTrue($this->Mail->addReplyTo('test+replyto@FRANÇOIS.CH'));
$this->assertFalse($this->Mail->addReplyTo('test+replyto@FRANÇOIS.CH'));
$this->assertTrue($this->Mail->addReplyTo('test+replyto@xn--franois-xxa.ch'));
$this->assertFalse($this->Mail->addReplyTo('test+replyto@xn--franois-xxa.ch'));
$this->assertFalse($this->Mail->addReplyTo('test+replyto@XN--FRANOIS-XXA.CH'));
$this->buildBody();
$this->assertTrue($this->Mail->send(), $this->Mail->ErrorInfo);
// There should be only one "To" address and one "Reply-To" address.
$this->assertEquals(1, count($this->Mail->getToAddresses()), 'Bad count of "to" recipients');
$this->assertEquals(1, count($this->Mail->getReplyToAddresses()), 'Bad count of "reply-to" addresses');
}
示例2: initMailFromSet
/**
* Inner mailer initialization from set variables
*
* @return void
*/
protected function initMailFromSet()
{
$this->mail->setLanguage($this->get('langLocale'), $this->get('langPath'));
$this->mail->CharSet = $this->get('charset');
$this->mail->From = $this->get('from');
$this->mail->FromName = $this->get('fromName') ?: $this->get('from');
$this->mail->Sender = $this->get('from');
$this->mail->clearAllRecipients();
$this->mail->clearAttachments();
$this->mail->clearCustomHeaders();
$emails = explode(static::MAIL_SEPARATOR, $this->get('to'));
foreach ($emails as $email) {
$this->mail->addAddress($email);
}
$this->mail->Subject = $this->get('subject');
$this->mail->AltBody = $this->createAltBody($this->get('body'));
$this->mail->Body = $this->get('body');
// add custom headers
foreach ($this->get('customHeaders') as $header) {
$this->mail->addCustomHeader($header);
}
if (is_array($this->get('images'))) {
foreach ($this->get('images') as $image) {
// Append to $attachment array
$this->mail->addEmbeddedImage($image['path'], $image['name'] . '@mail.lc', $image['name'], 'base64', $image['mime']);
}
}
}
示例3: send
/**
* Функция отправки сообщения:
*
* @param string $from - адрес отправителя
* @param string $from_name - имя отправителя
* @param string|array $to - адрес(-а) получателя
* @param string $theme - тема письма
* @param string $body - тело письма
* @param bool $isText - является ли тело письма текстом
*
* @return bool отправилось ли письмо
**/
public function send($from, $from_name, $to, $theme, $body, $isText = false)
{
$this->_mailer->clearAllRecipients();
$this->setFrom($from, $from_name);
if (is_array($to)) {
foreach ($to as $email) {
$this->addAddress($email);
}
} else {
$this->addAddress($to);
}
$this->setSubject($theme);
if ($isText) {
$this->_mailer->Body = $body;
$this->_mailer->isHTML(false);
} else {
$this->_mailer->msgHTML($body, \Yii::app()->basePath);
}
try {
return $this->_mailer->send();
} catch (\Exception $e) {
\Yii::log($e->__toString(), \CLogger::LEVEL_ERROR, 'mail');
return false;
}
}
示例4: testBCCAddressing
/**
* Test BCC-only addressing.
*/
public function testBCCAddressing()
{
$this->Mail->Subject .= ': BCC-only addressing';
$this->buildBody();
$this->Mail->clearAllRecipients();
$this->assertTrue($this->Mail->addBCC('a@example.com'), 'BCC addressing failed');
$this->assertTrue($this->Mail->send(), 'send failed');
}
示例5: clear
/**
* Clears out all previously specified values for this object and restores
* it to the state it was in when it was instantiated.
*
* @return Email
*/
public function clear()
{
$this->PhpMailer->clearAllRecipients();
$this->PhpMailer->Body = '';
$this->PhpMailer->AltBody = '';
$this->from();
$this->_IsToSet = false;
$this->mimeType(c('Garden.Email.MimeType', 'text/plain'));
$this->_MasterView = 'email.master';
$this->Skipped = array();
return $this;
}
示例6: send
/**
* 发送邮件
*
* @access public
* @param string $address 邮件地址
* @param string $subject 邮件标题
* @param string $content 邮件内容
* @return array
*/
public function send($address, $subject, $content)
{
$this->phpMailer->MsgHTML(eregi_replace("[\\]", '', $content));
$this->phpMailer->AddAddress($address, '');
if (!$this->phpMailer->Send()) {
#重置所有地址
$this->phpMailer->clearAllRecipients();
return array('isSuccess' => false, 'error' => $this->phpMailer->ErrorInfo);
} else {
#重置所有地址
$this->phpMailer->clearAllRecipients();
return array('isSuccess' => true);
}
}
示例7: __construct
/**
* $emailConfig['smtp'] = array(
* 'stmp_host' => '',
* 'user' => '',
* 'pwd' => '',
* 'port' => '',
* 'address' => '',
* );
*/
public function __construct()
{
$config = Config::Get('email', 'smtp');
$mailer = new PHPMailer();
$mailer->isSMTP();
$mailer->Host = $config['stmp_host'];
$mailer->Username = $config['user'];
$mailer->Password = $config['pwd'];
$mailer->SMTPAuth = true;
$mailer->Port = $config['port'];
$mailer->CharSet = "utf-8";
$mailer->setFrom($config['address']);
$mailer->isHTML();
$mailer->clearAllRecipients();
$this->phpMailer = $mailer;
}
示例8: reset
/**
* Resets the currently set mailer values back to there default values
*
* @return $this
*/
public function reset()
{
$this->subject = '';
$this->body = '';
$this->htmlBody = '';
$this->urlWeb = '';
$this->mailSignature = '';
$this->from = '';
$this->recipients = null;
$this->bcc = false;
$this->attachments = [];
$this->template = '';
if ($this->phpMailer) {
$this->phpMailer->clearAllRecipients();
$this->phpMailer->clearAttachments();
}
return $this;
}
示例9: clearAllRecipients
/**
* Clears all recipients assigned in the TO, CC and BCC
* array. Returns void.
*
* @return void
*/
public function clearAllRecipients()
{
$this->_aRecipients = array();
parent::clearAllRecipients();
}
示例10: send
/**
* Send the notification.
*
* This method sends the notification to all recipients, rendering the template with the corresponding parameters for each recipient.
* @throws phpmailerException The message could not be sent.
*/
public function send()
{
$mail = new \PHPMailer(true);
$mail->From = $this->from_email;
$mail->FromName = $this->from_name;
$mail->addReplyTo($this->reply_to_email, $this->reply_to_name);
$twig = static::$app->view()->getEnvironment();
// Loop through email recipients, sending customized content to each one
foreach ($this->email_recipients as $recipient) {
$mail->addAddress($recipient->getEmail(), $recipient->getName());
// Add any CCs and BCCs
if ($recipient->getCCs()) {
foreach ($recipient->getCCs() as $cc) {
$mail->addCC($cc['email'], $cc['name']);
}
}
if ($recipient->getBCCs()) {
foreach ($recipient->getBCCs() as $bcc) {
$mail->addBCC($bcc['email'], $bcc['name']);
}
}
$params = $recipient->getParams();
// Must manually merge in global variables for block rendering
$params = array_merge($twig->getGlobals(), $params);
$mail->Subject = $this->template->renderBlock('subject', $params);
$mail->Body = $this->template->renderBlock('body', $params);
$mail->isHTML(true);
// Set email format to HTML
// Send mail as SMTP, if desired
if (static::$app->config('mail') == 'smtp') {
$config = static::$app->config('smtp');
$mail->isSMTP(true);
$mail->Host = $config['host'];
$mail->Port = $config['port'];
$mail->SMTPAuth = $config['auth'];
$mail->SMTPSecure = $config['secure'];
$mail->Username = $config['user'];
$mail->Password = $config['pass'];
}
// Send mail as sendmail, if desired
if (static::$app->config('mail') == 'sendmail') {
$config = static::$app->config('sendmail');
$mail->isSendmail(true);
}
// Try to send the mail. Will throw an exception on failure.
$mail->send();
// Clear all PHPMailer recipients (from the message for this iteration)
$mail->clearAllRecipients();
}
}
示例11: mailer
/**
* Send email.
*
* @since 1.0
* @access public
* @param $type string
* @param $init array
*/
public function mailer($type = 'mail', $init = array())
{
global $wpdb, $guiform;
$subject = "";
$MsgHTML = "";
$sendTo = array_map('trim', explode(',', $init['to']));
$sendCc = array_map('trim', explode(',', $init['cc']));
$sendBcc = array_map('trim', explode(',', $init['bcc']));
$sendReplyTo = array_map('trim', explode(',', $init['reply-to']));
// Make sure the PHPMailer class has been instantiated
// (Re)create it, if it's gone missing
if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
require_once ABSPATH . WPINC . '/class-phpmailer.php';
require_once ABSPATH . WPINC . '/class-smtp.php';
$phpmailer = new PHPMailer(true);
$phpmailer->clearAllRecipients();
$phpmailer->SMTPAuth = true;
}
if ($type == 'test-mail') {
$data = $wpdb->get_row($wpdb->prepare("SELECT name, value FROM {$wpdb->guiform_options} WHERE id = %d", $this->_id));
$sendTo = array($data->name);
$row = unserialize($data->value);
$row = array_map('trim', $row);
$html = "<strong>" . __('Greetings!', GuiForm_Plugin::NAME) . "</strong><br /><br />";
$html .= __("This is a test message.", GuiForm_Plugin::NAME) . "<br /><br />";
$MsgHTML = self::emailTpl($html);
$phpmailer->SetFrom("noreply@guiform.com", GuiForm_Plugin::PACKAGE);
$phpmailer->Subject = __('Test Message', GuiForm_Plugin::NAME);
} else {
if ($type == 'activation-mail') {
$data = $wpdb->get_row($wpdb->prepare("SELECT name, value FROM {$wpdb->guiform_options} WHERE id = %d", $this->_id));
$row = unserialize($data->value);
$row = array_map('trim', $row);
$mv_code = md5(time());
$row['key'] = $mv_code;
$guiform->updateOption($data->name, $row, 'mail', $this->_id);
$phpmailer->Subject = __("Email Verification", GuiForm_Plugin::NAME);
$sendTo = array($data->name);
$vlink = get_site_url() . "/?" . $guiform->getOption('permalink')->value['value'] . '=' . $this->_id . "&mv-code={$mv_code}";
$html = "Hello " . $row['name'] . ",<br /><br />";
$html .= __("To enable this email address from sending emails with your forms we must first verify by clicking the link below:", GuiForm_Plugin::NAME) . "<br /><br />";
$html .= __("Verification Link: ", GuiForm_Plugin::NAME) . "<a target=\"_blank\" href=\"{$vlink}\">" . __("click here!", GuiForm_Plugin::NAME) . "</a><br /><br />";
$MsgHTML = self::emailTpl($html);
$phpmailer->SetFrom("noreply@guiform.com", "GuiForm");
} else {
if ($type == 'mail') {
$init['message'] = str_replace("\\r\\n", "<br />", $init['message']);
$init['message'] = stripcslashes($init['message']);
//Do not remove   and <br />.
$MsgHTML = $init['message'] . " <br />";
$phpmailer->SetFrom($init['from'], "");
$phpmailer->Subject = $init['subject'];
if (sizeof($init['attachment'])) {
foreach ($init['attachment'] as $file) {
$phpmailer->AddAttachment(self::getAttachmentPath($file['url']), $file['name']);
}
}
if (sizeof($sendReplyTo)) {
foreach ($sendReplyTo as $replyTo) {
if (is_email($replyTo)) {
$phpmailer->AddReplyTo($replyTo);
}
}
}
if (sizeof($sendCc)) {
foreach ($sendCc as $mailCc) {
if (is_email($mailCc)) {
$phpmailer->AddCC($mailCc);
}
}
}
if (sizeof($sendBcc)) {
foreach ($sendBcc as $mailBcc) {
if (is_email($mailBcc)) {
$phpmailer->AddCC($mailBcc);
}
}
}
}
}
}
$phpmailer->Body = html_entity_decode($MsgHTML);
$phpmailer->AltBody = strip_tags($MsgHTML);
$phpmailer->IsHTML(true);
$phpmailer->CharSet = "UTF-8";
foreach ($sendTo as $mailTo) {
if ($phpmailer->validateAddress($mailTo)) {
$phpmailer->AddAddress($mailTo);
}
}
$smtpSettings = $guiform->getOption($this->form, false, 'smtp')->value;
if ($smtpSettings->smtp_enable) {
//.........这里部分代码省略.........
示例12: sendEmail
public function sendEmail()
{
try {
$time = Manager::getSysTime();
$ipaddress = $_SERVER['REMOTE_ADDR'];
$mail = new PHPMailer();
$mail->IsSMTP();
// telling the class to use SMTP
$mail->Host = Manager::getConf('mailer.smtpServer');
// SMTP server
$mail->From = Manager::getConf('mailer.smtpFrom');
$mail->FromName = Manager::getConf('mailer.smtpFromName');
$mail->Subject = $this->data->assunto;
$mail->isHTML(false);
$mail->CharSet = 'utf-8';
$body = 'Enviada de: ' . $ipaddress . ' em ' . $time;
$mail->Body = $body . "\n" . $this->data->mensagem;
$mail->WordWrap = 100;
$mail->addAddress($this->data->email);
$ok = $mail->send();
$mail->clearAllRecipients();
$this->renderPrompt('information', 'Mensagem enviada com sucesso!');
} catch (Exception $e) {
$this->renderPrompt('error', $e->getMessage());
}
}
示例13: sendGmail
public static function sendGmail($username, $pass, array $email, $charset = 'UTF-8')
{
$mail = new PHPMailer();
$mail->isSMTP();
$mail->CharSet = $charset;
$mail->SMTPDebug = 0;
$mail->Host = GMAIL_HOST;
$mail->Port = GMAIL_PORT;
$mail->SMTPAuth = GMAIL_SMTP_AUTH;
$mail->SMTPSecure = GMAIL_SMTP_SECURE;
$mail->Username = $username;
$mail->Password = $pass;
foreach ($email as $to => $email_data) {
$mail->clearAllRecipients();
$mail->setFrom($username);
$mail->addAddress($to);
if (isset($email_data['cc'])) {
$mail->clearCCs();
foreach (is_array($email_data['cc']) ? $email_data['cc'] : [$email_data['cc']] as $cc) {
$mail->addCC($cc);
}
}
if (isset($email_data['bcc'])) {
$mail->clearBCCs();
foreach (is_array($email_data['bcc']) ? $email_data['bcc'] : [$email_data['bcc']] as $bcc) {
$mail->addBCC($bcc);
}
}
$mail->Subject = $email_data['subject'];
$mail->Body = $email_data['body'];
if (!$mail->send()) {
throw new Exception(__METHOD__ . $mail->ErrorInfo);
}
}
}
示例14: setMailAddress
/**
* @param string $mailAddress
*/
public function setMailAddress($mailAddress)
{
$this->mailer->clearAllRecipients();
self::checkMailValidity($mailAddress);
$this->mailer->addAddress($mailAddress);
}
示例15: send_mail
function send_mail($path, $mail_lock, $subject, $to = array())
{
if (!file_exists($mail_lock)) {
//从getwiki.php中得到的更新标志
$tmp_file = './update_' . time() . '.txt';
$ret_text = get_lastlog($path, 1);
//##########################################
$smtpserver = isset($_ENV["SMTP_SERVER"]) ? $_ENV["SMTP_SERVER"] : "smtp.163.com";
//SMTP服务器
$smtpserverport = isset($_ENV["SMTP_SERVER_PORT"]) ? $_ENV["SMTP_SERVER_PORT"] : "465";
//SMTP服务器端口
$smtpusermail = isset($_ENV["SMTP_USER_MAIL"]) ? $_ENV["SMTP_USER_MAIL"] : "";
//SMTP服务器的用户邮箱
$smtpemailto = isset($_ENV["SMTP_MAIL_TO"]) ? $_ENV["SMTP_MAIL_TO"] : "";
//收件人
$smtpuser = isset($_ENV["SMTP_USER"]) ? $_ENV["SMTP_USER"] : "";
//SMTP服务器的用户帐号
$smtppass = isset($_ENV["SMTP_PASS"]) ? $_ENV["SMTP_PASS"] : "";
//SMTP服务器的用户密码
$mailtype = "HTML";
//邮件格式(HTML/TXT),TXT为文本邮件
$mailsubject = "监测通知:微信公众平台WIKI更新";
//邮件主题
$mailbody = "<h1> 更新内容为: </h1>" . "git日志内容如下:<br><hr>" . nl2br(htmlspecialchars(substr($ret_text, 0, stripos($ret_text, "\ndiff --git")))) . "<br><hr>更多内容,请参看附件" . $tmp_file;
//邮件内容
##########################################
if (!$smtpuser) {
echo "由于邮箱SMTP账号信息等未配置,邮件未能发送<br />";
return false;
//未设置参数则返回
}
if (REMOTE_URL !== '') {
$mailbody .= "<br>或者点击查看远程仓库页面:<a href=\"" . REMOTE_URL . "\">" . REMOTE_URL . "</a>";
}
$mailbody .= '<hr>收到此邮件说明曾经订阅此通知,如不是您本人操作或不想再接收到此通知请单独向我发邮件说明或阅读
<a href="http://help.mail.163.com/faqDetail.do?code=d7a5dc8471cd0c0e8b4b8f4f8e49998b374173cfe9171305fa1ce630d7f67ac28425c7e6c5a286cc.">自助退订方法</a>';
if (empty($to)) {
$to = isset($_ENV["SMTP_MAIL_TO2"]) ? $_ENV["SMTP_MAIL_TO2"] : "";
//附加收件人
}
$to_arr = preg_split('/[,;\\/\\\\|]/', $smtpemailto);
if (is_string($to)) {
$to = preg_split('/[,;\\/\\\\|]/', $to);
}
$to_arr = array_merge($to_arr, $to);
$to_count = count($to_arr);
$to_arr = array_chunk($to_arr, 20);
write($tmp_file, $ret_text);
$mail = new PHPMailer();
$mail->IsSMTP();
// send via SMTP
//$mail->SMTPDebug = 1;
$mail->SMTPAuth = true;
// turn on SMTP authentication
$mail->SMTPSecure = "ssl";
$mail->CharSet = "utf-8";
// 这里指定字符集!
$mail->Encoding = "base64";
$mail->Host = $smtpserver;
// SMTP servers
$mail->Port = $smtpserverport;
$mail->Username = $smtpuser;
// SMTP username 注意:普通邮件认证不需要加 @域名
$mail->Password = $smtppass;
// SMTP password
$mail->setFrom($smtpusermail, "Auto Robot");
//设置发件人信息
$mail->AddReplyTo($smtpusermail);
//回复地址和姓名
$mail->WordWrap = 50;
// set word wrap
$mail->IsHTML(true);
// send as HTML
$mail->Subject = $subject ? $subject : $mailsubject;
// 邮件主题
$mail->Body = $mailbody;
$mail->AltBody = "text/html";
$mail->addAttachment($tmp_file);
$sendRet = true;
foreach ($to_arr as $to_arr_lite) {
foreach ($to_arr_lite as $to_str) {
$mail->AddAddress($to_str);
// 收件人邮箱和姓名
}
$sendRet = $mail->Send() & $sendRet;
$mail->clearAllRecipients();
}
if ($sendRet) {
unlink($tmp_file);
echo "邮件发送失败,";
echo "邮件错误信息: " . $mail->ErrorInfo . "<br />";
} else {
unlink($tmp_file);
echo "邮件已发送到邮箱 <br />";
file_put_contents($mail_lock, 'ok');
}
} else {
echo "未更新,不发送通知邮件。";
}
}