本文整理汇总了PHP中PHPMailer::AddCustomHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPMailer::AddCustomHeader方法的具体用法?PHP PHPMailer::AddCustomHeader怎么用?PHP PHPMailer::AddCustomHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPMailer
的用法示例。
在下文中一共展示了PHPMailer::AddCustomHeader方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mailer_to
function mailer_to($to, $subject, $body)
{
require_once "class.phpmailer.php";
$mail3 = new PHPMailer();
$mail3->IsSMTP();
// telling the class to use SMTP
$mail3->Host = "mail.pp3.co.id";
// SMTP server
$mail3->SMTPAuth = true;
// enable SMTP authentication
$mail3->SMTPSecure = "ntlm";
// sets the prefix to the servier
$mail3->IsHTML(true);
$mail3->Username = "support.si@pp3.co.id";
// GMAIL username
$mail3->Password = "pelindo3pusat";
// GMAIL password
$mail3->SetFrom('support_si@pp3.co.id', 'Subdit. Sistem Informasi Kantor Pusat Pelindo III');
$mail3->AddAddress($to);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= "From: support_si@pp3.co.id <Subdit. Sistem Informasi Kantor Pusat Pelindo III>\r\n";
$mail3->Subject = $subject;
$mail3->Body = $body;
$mail3->AddCustomHeader($headers);
$mail3->WordWrap = 100;
if (!$mail3->Send()) {
echo 'Email tidak terkirim.';
echo 'Mailer error: ' . $mail3->ErrorInfo;
} else {
echo 'Email Terkirim.<br>';
}
}
示例2: create
/**
* Creates new instance of PHPMailer and set default options from config
* @api
* @throws ComponentException
* @throws \phpmailerException
* @return \PHPMailer
*/
public function create()
{
// can initial, can't use
if (!class_exists('\\PHPMailer')) {
throw new ComponentException("PHPMailer library is required for `Bluz\\Mailer` package. <br/>\n" . "Read more: <a href='https://github.com/bluzphp/framework/wiki/Mailer'>" . "https://github.com/bluzphp/framework/wiki/Mailer</a>");
}
$mail = new \PHPMailer();
$mail->WordWrap = 920;
// RFC 2822 Compliant for Max 998 characters per line
$fromEmail = $this->getOption('from', 'email');
$fromName = $this->getOption('from', 'name') ?: '';
// setup options from config
$mail->SetFrom($fromEmail, $fromName, false);
// setup options
if ($settings = $this->getOption('settings')) {
foreach ($settings as $name => $value) {
$mail->set($name, $value);
}
}
// setup custom headers
if ($headers = $this->getOption('headers')) {
foreach ($headers as $header => $value) {
$mail->AddCustomHeader($header, $value);
}
}
return $mail;
}
示例3: 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('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']);
}
}
}
示例4:
/**
* Miscellaneous calls to improve test coverage and some small tests
*/
function test_Miscellaneous()
{
$this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
$this->Mail->AddCustomHeader('SomeHeader: Some Value');
$this->Mail->ClearCustomHeaders();
$this->Mail->ClearAttachments();
$this->Mail->IsHTML(false);
$this->Mail->IsSMTP();
$this->Mail->IsMail();
$this->Mail->IsSendMail();
$this->Mail->IsQmail();
$this->Mail->SetLanguage('fr');
$this->Mail->Sender = '';
$this->Mail->CreateHeader();
$this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
$this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
//Test pathinfo
$a = '/mnt/files/飛兒樂 團光茫.mp3';
$q = PHPMailer::mb_pathinfo($a);
$this->assertEquals($q['dirname'], '/mnt/files', 'UNIX dirname not matched');
$this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'UNIX basename not matched');
$this->assertEquals($q['extension'], 'mp3', 'UNIX extension not matched');
$this->assertEquals($q['filename'], '飛兒樂 團光茫', 'UNIX filename not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, PATHINFO_DIRNAME), '/mnt/files', 'Dirname path element not matched');
$this->assertEquals(PHPMailer::mb_pathinfo($a, 'filename'), '飛兒樂 團光茫', 'Filename path element not matched');
$a = 'c:\\mnt\\files\\飛兒樂 團光茫.mp3';
$q = PHPMailer::mb_pathinfo($a);
$this->assertEquals($q['dirname'], 'c:\\mnt\\files', 'Windows dirname not matched');
$this->assertEquals($q['basename'], '飛兒樂 團光茫.mp3', 'Windows basename not matched');
$this->assertEquals($q['extension'], 'mp3', 'Windows extension not matched');
$this->assertEquals($q['filename'], '飛兒樂 團光茫', 'Windows filename not matched');
}
示例5: AddCustomHeader
/**
* Extended AddCustomHeader function in order to stop duplicate
* message-ids
* http://tracker.moodle.org/browse/MDL-3681
*/
public function AddCustomHeader($custom_header)
{
if (preg_match('/message-id:(.*)/i', $custom_header, $matches)) {
$this->MessageID = $matches[1];
return true;
} else {
return parent::AddCustomHeader($custom_header);
}
}
示例6: send
function send($o, $to, $from, $subject, $body, $headers)
{
$mail = new PHPMailer(true);
$mail->IsSMTP();
$mail->SMTPDebug = 0;
// enables SMTP debug information (for testing)
$mail->SMTPAuth = $this->api->getConfig("tmail/phpmailer/username", null) ? true : false;
// enable SMTP authentication
$mail->Host = $this->api->getConfig("tmail/smtp/host");
$mail->Port = $this->api->getConfig("tmail/smtp/port");
$mail->Username = $this->api->getConfig("tmail/phpmailer/username", null);
$mail->Password = $this->api->getConfig("tmail/phpmailer/password", null);
$mail->SMTPSecure = 'tls';
$mail->AddReplyTo($this->api->getConfig("tmail/phpmailer/reply_to"), $this->api->getConfig("tmail/phpmailer/reply_to_name"));
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->MsgHTML($body);
$mail->AltBody = null;
$mail->IsHTML(true);
$bcc = $this->api->getConfig("tmail/phpmailer/bcc", null);
if ($bcc) {
$bcc_name = $this->api->getConfig("tmail/phpmailer/bcc_name", null);
$mail->AddBCC($bcc, $bcc_name);
}
$internal_header_map = array("Content-Type" => "ContentType");
$void_headers = array("MIME-Version");
$fromAdded = false;
foreach (explode("\n", $headers) as $h) {
if (preg_match("/^(.*?):(.*)\$/", $h, $t)) {
if (strtolower($t[1]) == "from" && $t[2]) {
$mail->SetFrom($t[2]);
$fromAdded = true;
continue;
}
if (isset($internal_header_map[$t[1]])) {
$key = $internal_header_map[$t[1]];
$mail->{$key} = $t[2];
continue;
} else {
if (in_array($t[1], $void_headers)) {
continue;
}
}
}
$mail->AddCustomHeader($h);
}
if (!$fromAdded) {
$mail->SetFrom($this->api->getConfig("tmail/phpmailer/from"), $from ? "" : $this->api->getConfig("tmail/phpmailer/from_name"));
$mail->AddReplyTo($this->api->getConfig("tmail/phpmailer/reply_to"), $this->api->getConfig("tmail/phpmailer/reply_to_name"));
}
$mail->Send();
}
示例7: mail
public function mail($to, $subj, $body, $headers = false, $params = false)
{
$mail = new PHPMailer();
$mail->IsSMTP();
// set mailer to use SMTP
$mail->Host = "mail.inversiondesigns.com";
// specify main and backup server
$mail->SMTPAuth = true;
// turn on SMTP authentication
$mail->Username = "bot@promotro.com";
// SMTP username
$mail->Password = "r4tb4ndit";
// SMTP password
$mail->AddAddress($to);
if (is_string($headers)) {
$headers = explode("\n", $headers);
foreach ($headers as $header) {
$h = explode(":", $header, 2);
if (stripos($h[0], "From") !== false) {
$from = $h[1];
if (stripos($from, "<") !== false) {
$start = strpos($from, "<") + 1;
$mail->From = substr($from, $start, strpos($from, ">") - $start);
$mail->FromName = substr($from, 0, strpos($from, "<"));
} else {
$mail->From = $h[1];
$mail->FromName = $h[1];
}
} else {
$mail->AddCustomHeader(trim($header));
}
}
} else {
$mail->From = "bot@inversiondesigns.com";
$mail->FromName = "Inversion Bot";
$mail->AddReplyTo("noreply@inversiondesigns.com", "No Reply");
}
//$mail->WordWrap = 50; // set word wrap to 50 characters
$mail->IsHTML(true);
// set email format to HTML
$mail->Subject = $subj;
$mail->Body = $body;
$mail->AltBody = strip_tags($body);
$result = $mail->Send();
$mail->close();
return $result;
}
示例8:
function phpmailer_init_smtp(PHPMailer $phpmailer)
{
if (!get_option('mailjet_enabled') || 0 == get_option('mailjet_enabled')) {
return;
}
$phpmailer->Mailer = 'smtp';
$phpmailer->SMTPSecure = get_option('mailjet_ssl');
$phpmailer->Host = MJ_HOST;
$phpmailer->Port = get_option('mailjet_port');
$phpmailer->SMTPAuth = TRUE;
$phpmailer->Username = get_option('mailjet_username');
$phpmailer->Password = get_option('mailjet_password');
$from_email = get_option('mailjet_from_email') ? get_option('mailjet_from_email') : get_option('admin_email');
$phpmailer->From = $from_email;
$phpmailer->Sender = $from_email;
$phpmailer->AddCustomHeader(MJ_MAILER);
}
示例9:
/**
* Miscellaneous calls to improve test coverage and some small tests
*/
function test_Miscellaneous()
{
$this->assertEquals('application/pdf', PHPMailer::_mime_types('pdf'), 'MIME TYPE lookup failed');
$this->Mail->AddCustomHeader('SomeHeader: Some Value');
$this->Mail->ClearCustomHeaders();
$this->Mail->ClearAttachments();
$this->Mail->IsHTML(false);
$this->Mail->IsSMTP();
$this->Mail->IsMail();
$this->Mail->IsSendMail();
$this->Mail->IsQmail();
$this->Mail->SetLanguage('fr');
$this->Mail->Sender = '';
$this->Mail->CreateHeader();
$this->assertFalse($this->Mail->set('x', 'y'), 'Invalid property set succeeded');
$this->assertTrue($this->Mail->set('Timeout', 11), 'Valid property set failed');
}
示例10: sendEmail
public static function sendEmail($vars, $email, $body, $alt, $clicktrack = true)
{
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Username = CShell::SMTPUN();
$mail->Password = CShell::SMTPPW();
$mail->IsHTML(true);
$mail->SetFrom($vars["from"]);
$mail->FromName = $vars["name"];
$mail->AddReplyTo($vars["reply"]);
$mail->Subject = $vars["subject"];
$mail->MsgHTML($body);
$mail->AltBody = $alt;
$x_smtpapi = array('category' => array('webinar', $vars['category']));
if (!$clicktrack) {
$x_smtpapi['filters'] = array('clicktrack' => array('settings' => array('enable' => 0)));
}
$blah = 'X-SMTPAPI: ' . json_encode($x_smtpapi);
$mail->AddCustomHeader($blah);
$mail->AddAddress($email);
$response = $mail->Send();
$mail->ClearAddresses();
return $response;
}
示例11: api_mail_html
/**
* Sends an HTML email using the phpmailer class (and multipart/alternative to downgrade gracefully)
* Sender name and email can be specified, if not specified
* name and email of the platform admin are used
*
* @author Bert Vanderkimpen ICT&O UGent
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*
* @param string name of recipient
* @param string email of recipient
* @param string email subject
* @param string email body
* @param string sender name
* @param string sender e-mail
* @param array extra headers in form $headers = array($name => $value) to allow parsing
* @param array data file (path and filename)
* @param array data to attach a file (optional)
* @param bool True for attaching a embedded file inside content html (optional)
* @return returns true if mail was sent
* @see class.phpmailer.php
*/
function api_mail_html($recipient_name, $recipient_email, $subject, $message, $senderName = '', $senderEmail = '', $extra_headers = array(), $data_file = array(), $embedded_image = false, $additionalParameters = array())
{
global $platform_email;
$mail = new PHPMailer();
$mail->Mailer = $platform_email['SMTP_MAILER'];
$mail->Host = $platform_email['SMTP_HOST'];
$mail->Port = $platform_email['SMTP_PORT'];
$mail->CharSet = $platform_email['SMTP_CHARSET'];
// Stay far below SMTP protocol 980 chars limit.
$mail->WordWrap = 200;
if ($platform_email['SMTP_AUTH']) {
$mail->SMTPAuth = 1;
$mail->Username = $platform_email['SMTP_USER'];
$mail->Password = $platform_email['SMTP_PASS'];
}
// 5 = low, 1 = high
$mail->Priority = 3;
$mail->SMTPKeepAlive = true;
// Default values
$notification = new Notification();
$defaultEmail = $notification->getDefaultPlatformSenderEmail();
$defaultName = $notification->getDefaultPlatformSenderName();
// Error to admin.
$mail->AddCustomHeader('Errors-To: ' . $defaultEmail);
// If the parameter is set don't use the admin.
$senderName = !empty($senderName) ? $senderName : $defaultEmail;
$senderEmail = !empty($senderEmail) ? $senderEmail : $defaultName;
// Reply to first
if (isset($extra_headers['reply_to'])) {
$mail->AddReplyTo($extra_headers['reply_to']['mail'], $extra_headers['reply_to']['name']);
$mail->Sender = $extra_headers['reply_to']['mail'];
unset($extra_headers['reply_to']);
}
$mail->SetFrom($senderEmail, $senderName);
$mail->Subject = $subject;
$mail->AltBody = strip_tags(str_replace('<br />', "\n", api_html_entity_decode($message)));
// Send embedded image.
if ($embedded_image) {
// Get all images html inside content.
preg_match_all("/<img\\s+.*?src=[\"\\']?([^\"\\' >]*)[\"\\']?[^>]*>/i", $message, $m);
// Prepare new tag images.
$new_images_html = array();
$i = 1;
if (!empty($m[1])) {
foreach ($m[1] as $image_path) {
$real_path = realpath($image_path);
$filename = basename($image_path);
$image_cid = $filename . '_' . $i;
$encoding = 'base64';
$image_type = mime_content_type($real_path);
$mail->AddEmbeddedImage($real_path, $image_cid, $filename, $encoding, $image_type);
$new_images_html[] = '<img src="cid:' . $image_cid . '" />';
$i++;
}
}
// Replace origin image for new embedded image html.
$x = 0;
if (!empty($m[0])) {
foreach ($m[0] as $orig_img) {
$message = str_replace($orig_img, $new_images_html[$x], $message);
$x++;
}
}
}
$message = str_replace(array("\n\r", "\n", "\r"), '<br />', $message);
$mail->Body = '<html><head></head><body>' . $message . '</body></html>';
// Attachment ...
if (!empty($data_file)) {
$mail->AddAttachment($data_file['path'], $data_file['filename']);
}
// Only valid addresses are accepted.
if (is_array($recipient_email)) {
foreach ($recipient_email as $dest) {
if (api_valid_email($dest)) {
$mail->AddAddress($dest, $recipient_name);
}
}
} else {
if (api_valid_email($recipient_email)) {
//.........这里部分代码省略.........
示例12: array
//.........这里部分代码省略.........
$boundary = trim(str_replace(array('BOUNDARY=', 'boundary=', '"'), '', $charset));
$charset = '';
}
} else {
$content_type = trim($content);
}
} elseif ('cc' == strtolower($name)) {
$cc = explode(",", $content);
} elseif ('bcc' == strtolower($name)) {
$bcc = explode(",", $content);
} else {
// Add it to our grand headers array
$headers[trim($name)] = trim($content);
}
}
}
}
// Empty out the values that may be set
$bb_phpmailer->ClearAddresses();
$bb_phpmailer->ClearAllRecipients();
$bb_phpmailer->ClearAttachments();
$bb_phpmailer->ClearBCCs();
$bb_phpmailer->ClearCCs();
$bb_phpmailer->ClearCustomHeaders();
$bb_phpmailer->ClearReplyTos();
// From email and name
// If we don't have a name from the input headers
if (!isset($from_name)) {
$from_name = bb_get_option('name');
}
// If we don't have an email from the input headers
if (!isset($from_email)) {
$from_email = bb_get_option('from_email');
}
// If there is still no email address
if (!$from_email) {
// Get the site domain and get rid of www.
$sitename = strtolower($_SERVER['SERVER_NAME']);
if (substr($sitename, 0, 4) == 'www.') {
$sitename = substr($sitename, 4);
}
$from_email = 'bbpress@' . $sitename;
}
// Plugin authors can override the potentially troublesome default
$bb_phpmailer->From = apply_filters('bb_mail_from', $from_email);
$bb_phpmailer->FromName = apply_filters('bb_mail_from_name', $from_name);
// Set destination address
$bb_phpmailer->AddAddress($to);
// Set mail's subject and body
$bb_phpmailer->Subject = $subject;
$bb_phpmailer->Body = $message;
// Add any CC and BCC recipients
if (!empty($cc)) {
foreach ((array) $cc as $recipient) {
$bb_phpmailer->AddCc(trim($recipient));
}
}
if (!empty($bcc)) {
foreach ((array) $bcc as $recipient) {
$bb_phpmailer->AddBcc(trim($recipient));
}
}
// Set to use PHP's mail()
$bb_phpmailer->IsMail();
// Set Content-Type and charset
// If we don't have a content-type from the input headers
if (!isset($content_type)) {
$content_type = 'text/plain';
}
$content_type = apply_filters('bb_mail_content_type', $content_type);
$bb_phpmailer->ContentType = $content_type;
// Set whether it's plaintext or not, depending on $content_type
if ($content_type == 'text/html') {
$bb_phpmailer->IsHTML(true);
}
// If we don't have a charset from the input headers
if (!isset($charset)) {
$charset = bb_get_option('charset');
}
// Set the content-type and charset
$bb_phpmailer->CharSet = apply_filters('bb_mail_charset', $charset);
// Set custom headers
if (!empty($headers)) {
foreach ((array) $headers as $name => $content) {
$bb_phpmailer->AddCustomHeader(sprintf('%1$s: %2$s', $name, $content));
}
if (false !== stripos($content_type, 'multipart') && !empty($boundary)) {
$bb_phpmailer->AddCustomHeader(sprintf("Content-Type: %s;\n\t boundary=\"%s\"", $content_type, $boundary));
}
}
if (!empty($attachments)) {
foreach ($attachments as $attachment) {
$bb_phpmailer->AddAttachment($attachment);
}
}
do_action_ref_array('bb_phpmailer_init', array(&$bb_phpmailer));
// Send!
$result = @$bb_phpmailer->Send();
return $result;
}
示例13: send_mail
function send_mail($rec_email, $subject, $message, $IsHtml = false, $cc = array(), $bcc = array())
{
global $THIS_BASEPATH, $btit_settings;
if (!method_exists('PHPMailer', 'IsMail')) {
include $THIS_BASEPATH . '/phpmailer/class.phpmailer.php';
}
$mail = new PHPMailer();
if ($btit_settings['mail_type'] == 'php') {
$mail->IsMail();
# send via mail
if (!empty($cc)) {
$mail->AddCustomHeader('Cc: ' . implode(',', $cc));
}
if (!empty($bcc)) {
$mail->AddCustomHeader('Bcc: ' . implode(',', $bcc));
}
} else {
$mail->IsSMTP();
# send via SMTP
$mail->Host = $btit_settings['smtp_server'];
# SMTP servers
$mail->Port = $btit_settings['smtp_port'];
# SMTP port
$mail->SMTPAuth = true;
# turn on SMTP authentication
$mail->Username = $btit_settings['smtp_username'];
# SMTP username
$mail->Password = $btit_settings['smtp_password'];
# SMTP password
if (!empty($cc)) {
foreach ($cc as $carbon_copy) {
$mail->AddCC($carbon_copy[0], $carbon_copy[0]);
}
}
if (!empty($bcc)) {
foreach ($bcc as $blind_carbon_copy) {
$mail->AddBCC($blind_carbon_copy[0], $blind_carbon_copy[0]);
}
}
}
$mail->From = $btit_settings['email'];
$mail->FromName = $btit_settings['name'];
$mail->CharSet = $btit_settings['default_charset'];
$mail->IsHTML($IsHtml);
$mail->AddAddress($rec_email);
$mail->AddReplyTo($btit_settings['email'], $btit_settings['name']);
$mail->Subject = $subject;
$mail->Body = $message;
return $mail->Send() ? true : $mail->ErrorInfo;
}
示例14: send
//.........这里部分代码省略.........
if (!($mail['recipients'] = $this->parse_emails_deep($mail['recipients']))) {
throw $this->©exception($this->method(__FUNCTION__) . '#recipients_missing', get_defined_vars(), $this->__('Email failure. Missing and/or invalid `recipients` value.'));
}
// Possible header(s).
if ($this->©string->is_not_empty($mail['headers'])) {
$mail['headers'] = array($mail['headers']);
}
$this->©array->isset_or($mail['headers'], array(), TRUE);
// Standardize/validate each header.
foreach ($mail['headers'] as $_header) {
if (!$this->©string->is_not_empty($_header)) {
throw $this->©exception($this->method(__FUNCTION__) . '#header_missing', get_defined_vars(), $this->__('Email failure. Missing and/or invalid `header`.') . ' ' . sprintf($this->__('Got: `%1$s`.'), $this->©var->dump($_header)));
}
}
unset($_header);
// Just a little housekeeping.
// Possible file attachment(s).
if ($this->©string->is_not_empty($mail['attachments'])) {
$mail['attachments'] = array($mail['attachments']);
}
$this->©array->isset_or($mail['attachments'], array(), TRUE);
// Standardize/validate each attachment.
foreach ($mail['attachments'] as &$_attachment) {
if (!is_array($_attachment)) {
$_attachment = array('path' => $_attachment);
}
if (!$this->©string->is_not_empty($_attachment['path'])) {
throw $this->©exception($this->method(__FUNCTION__) . '#attachment_path_missing', get_defined_vars(), $this->__('Email failure. Missing and/or invalid attachment `path` value.') . ' ' . sprintf($this->__('Got: `%1$s`.'), $this->©var->dump($_attachment)));
}
if (!is_file($_attachment['path'])) {
// Perhaps relative?
if (!is_file(ABSPATH . $_attachment['path'])) {
throw $this->©exception($this->method(__FUNCTION__) . '#nonexistent_attachment_path', get_defined_vars(), $this->__('Email failure. Nonexistent attachment `path` value.') . ' ' . sprintf($this->__('Got: `%1$s`.'), $this->©var->dump($_attachment)));
} else {
$_attachment['path'] = ABSPATH . $_attachment['path'];
}
}
if (!$this->©string->is_not_empty($_attachment['name'])) {
$_attachment['name'] = basename($_attachment['path']);
}
if (!$this->©string->is_not_empty($_attachment['encoding'])) {
$_attachment['encoding'] = 'base64';
}
// Default encoding.
if (!$this->©string->is_not_empty($_attachment['mime_type'])) {
$_attachment['mime_type'] = $this->©file->mime_type($_attachment['path']);
}
}
unset($_attachment);
// Just a little housekeeping.
try {
$mailer = new \PHPMailer(TRUE);
$mailer->IsMail();
$mailer->SingleTo = TRUE;
$mailer->CharSet = 'UTF-8';
$mailer->Subject = $mail['subject'];
$mailer->SetFrom($mail['from_addr'], $mail['from_name']);
foreach ($mail['recipients'] as $_recipient_addr) {
$mailer->AddAddress($_recipient_addr);
}
unset($_recipient_addr);
foreach ($mail['headers'] as $_header) {
$mailer->AddCustomHeader($_header);
}
unset($_header);
// Housekeeping.
if (!$this->©string->is_html($mail['message'])) {
$mail['message'] = nl2br(esc_html($mail['message']));
}
$mailer->MsgHTML($mail['message']);
foreach ($mail['attachments'] as $_attachment) {
$mailer->AddAttachment($_attachment['path'], $_attachment['name'], $_attachment['encoding'], $_attachment['mime_type']);
}
unset($_attachment);
// Housekeeping.
if ($this->©option->get('mail.smtp')) {
$mailer->IsSMTP();
// Flag for SMTP use in this case.
$mailer->SMTPSecure = $this->©option->get('mail.smtp.secure');
$mailer->Host = $this->©option->get('mail.smtp.host');
$mailer->Port = (int) $this->©option->get('mail.smtp.port');
$mailer->SMTPAuth = (bool) $this->©option->get('mail.smtp.username');
$mailer->Username = $this->©option->get('mail.smtp.username');
$mailer->Password = $this->©option->get('mail.smtp.password');
if ($this->©option->get('mail.smtp.force_from') && $this->©option->get('mail.smtp.from_addr')) {
$mailer->SetFrom($this->©option->get('mail.smtp.from_addr'), $this->©option->get('mail.smtp.from_name'));
}
}
do_action('phpmailer_init', $mailer);
// WP Mail SMTP, and others like it need this.
$mailer->Send();
// Send this email message.
} catch (\phpmailerException $exception) {
return $this->©error($this->method(__FUNCTION__), get_defined_vars(), $exception->getMessage());
} catch (\exception $exception) {
return $this->©error($this->method(__FUNCTION__), get_defined_vars(), $exception->getMessage());
}
return TRUE;
// Default return value.
}
示例15: pgvMail
//.........这里部分代码省略.........
$extraHeaders .= "\nMime-Version: 1.0";
}
$extraHeaders .= "\n";
if ($mailFormat == "html") {
//wrap message in html
$htmlMessage = "";
$htmlMessage .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
$htmlMessage .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
$htmlMessage .= "<head>";
$htmlMessage .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
$htmlMessage .= "</head>";
$htmlMessage .= "<body dir=\"{$TEXT_DIRECTION}\"><pre>";
$htmlMessage .= $message;
//add message
$htmlMessage .= "</pre></body>";
$htmlMessage .= "</html>";
$message = $htmlMessage;
} else {
if ($mailFormat == "multipart") {
//wrap message in html
$htmlMessage = "--{$boundary}\n";
$htmlMessage .= "Content-Type: multipart/alternative; \n\tboundary=--{$boundary2}\n\n";
$htmlMessage = "--{$boundary2}\n";
$htmlMessage .= "Content-Type: text/plain; \n\tcharset=\"{$CHARACTER_SET}\";\n\tformat=\"flowed\"\nContent-Transfer-Encoding: 8bit\n\n";
$htmlMessage .= $message;
$htmlMessage .= "\n\n--{$boundary2}\n";
$htmlMessage .= "Content-Type: text/html; \n\tcharset=\"{$CHARACTER_SET}\";\n\tformat=\"flowed\"\nContent-Transfer-Encoding: 8bit\n\n";
$htmlMessage .= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
$htmlMessage .= "<html xmlns=\"http://www.w3.org/1999/xhtml\">";
$htmlMessage .= "<head>";
$htmlMessage .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />";
$htmlMessage .= "</head>";
$htmlMessage .= "<body dir=\"{$TEXT_DIRECTION}\"><pre>";
$htmlMessage .= $message;
//add message
$htmlMessage .= "</pre>";
$htmlMessage .= "<img src=\"cid:pgvlogo@pgvserver\" alt=\"\" style=\"border: 0px; display: block; margin-left: auto; margin-right: auto;\" />";
$htmlMessage .= "</body>";
$htmlMessage .= "</html>";
$htmlMessage .= "\n--{$boundary2}--\n";
$htmlMessage .= "\n--{$boundary}\n";
$htmlMessage .= getPgvMailLogo();
$htmlMessage .= "\n\n\n\n--{$boundary}--";
$message = $htmlMessage;
}
}
// if SMTP mail is set active AND we have SMTP settings available, use the PHPMailer classes
if ($PGV_SMTP_ACTIVE && ($PGV_SMTP_HOST && $PGV_SMTP_PORT)) {
require_once 'includes/class.phpmailer.php';
$mail_object = new PHPMailer();
$mail_object->IsSMTP();
$mail_object->SetLanguage('en', 'languages/');
if ($PGV_SMTP_AUTH && ($PGV_SMTP_AUTH_USER && $PGV_SMTP_AUTH_PASS)) {
$mail_object->SMTPAuth = $PGV_SMTP_AUTH;
$mail_object->Username = $PGV_SMTP_AUTH_USER;
$mail_object->Password = $PGV_SMTP_AUTH_PASS;
}
if ($PGV_SMTP_SSL == 'ssl') {
$mail_object->SMTPSecure = 'ssl';
} else {
if ($PGV_SMTP_SSL == 'tls') {
$mail_object->SMTPSecure = 'tls';
}
}
$mail_object->Host = $PGV_SMTP_HOST;
$mail_object->Port = $PGV_SMTP_PORT;
$mail_object->Hostname = $PGV_SMTP_HELO;
$mail_object->From = $from;
if (!empty($PGV_SMTP_FROM_NAME) && $from != $PGV_SMTP_AUTH_USER) {
$mail_object->FromName = $PGV_SMTP_FROM_NAME;
$mail_object->AddAddress($to);
} else {
$mail_object->FromName = $mail_object->AddAddress($to);
}
$mail_object->Subject = hex4email($subject, $CHARACTER_SET);
$mail_object->ContentType = $mailFormatText;
if ($mailFormat != "multipart") {
$mail_object->ContentType = $mailFormatText . '; format="flowed"';
$mail_object->CharSet = $CHARACTER_SET;
$mail_object->Encoding = '8bit';
}
if ($mailFormat == "html" || $mailFormat == "multipart") {
$mail_object->AddCustomHeader('Mime-Version: 1.0');
$mail_object->IsHTML(true);
}
$mail_object->Body = $message;
// attempt to send mail
if (!$mail_object->Send()) {
echo 'Message was not sent.<br />';
echo 'Mailer error: ' . $mail_object->ErrorInfo . '<br />';
return;
} else {
// SMTP OK
return;
}
} else {
// use original PGV mail sending function
mail($to, hex4email($subject, $CHARACTER_SET), $message, $extraHeaders);
}
}