本文整理汇总了PHP中phpmailer::AddCustomHeader方法的典型用法代码示例。如果您正苦于以下问题:PHP phpmailer::AddCustomHeader方法的具体用法?PHP phpmailer::AddCustomHeader怎么用?PHP phpmailer::AddCustomHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpmailer
的用法示例。
在下文中一共展示了phpmailer::AddCustomHeader方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: email_to_user
//.........这里部分代码省略.........
echo '<pre>' . "\n";
$mail->SMTPDebug = true;
}
$mail->Host = $CFG->smtphosts;
// specify main and backup servers
if ($CFG->smtpuser) {
// Use SMTP authentication
$mail->SMTPAuth = true;
$mail->Username = $CFG->smtpuser;
$mail->Password = $CFG->smtppass;
}
}
}
/* not here yet, leave it in just in case.
// make up an email address for handling bounces
if (!empty($CFG->handlebounces)) {
$modargs = 'B'.base64_encode(pack('V',$user->ident)).substr(md5($user->email),0,16);
$mail->Sender = generate_email_processing_address(0,$modargs);
}
else {
$mail->Sender = $CFG->sysadminemail;
}
*/
$mail->Sender = $CFG->sysadminemail;
// for elgg. delete if we change the above.
// TODO add a preference for maildisplay
if (is_string($from)) {
// So we can pass whatever we want if there is need
$mail->From = $CFG->noreplyaddress;
$mail->FromName = $from;
} else {
if (empty($from)) {
// make stuff up
$mail->From = $CFG->sysadminemail;
$mail->FromName = $CFG->sitename . ' ' . __gettext('Administrator');
} else {
if ($usetrueaddress and !empty($from->maildisplay)) {
$mail->From = $from->email;
$mail->FromName = $from->name;
} else {
$mail->From = $CFG->noreplyaddress;
$mail->FromName = $from->name;
if (empty($replyto)) {
$mail->AddReplyTo($CFG->noreplyaddress, __gettext('Do not reply'));
}
}
}
}
if (!empty($replyto)) {
$mail->AddReplyTo($replyto, $replytoname);
}
$mail->Subject = $textlib->substr(stripslashes($subject), 0, 900);
$mail->AddAddress($user->email, $user->name);
$mail->WordWrap = 79;
// set word wrap
if (!empty($from->customheaders)) {
// Add custom headers
if (is_array($from->customheaders)) {
foreach ($from->customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
}
} else {
$mail->AddCustomHeader($from->customheaders);
}
}
if (!empty($from->priority)) {
$mail->Priority = $from->priority;
}
//TODO add a user preference for this. right now just send plaintext
$user->mailformat = 0;
if ($messagehtml && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
// Encoding to use
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (ereg("\\.\\.", $attachment)) {
// Security check for ".." in dir path
$mail->AddAddress($CFG->sysadminemail, $CFG->sitename . ' ' . __gettext('Administrator'));
$mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$mail->AddAttachment($attachment, $attachname, 'base64', $mimetype);
}
}
if ($mail->Send()) {
// set_send_count($user); // later
return true;
} else {
mtrace('ERROR: ' . $mail->ErrorInfo);
return false;
}
}
示例2: email_user
/**
* Always use this function for all emails to users
*
* @param object $userto user object to send email to. must contain firstname,lastname,preferredname,email
* @param object $userfrom user object to send email from. If null, email will come from mahara
* @param string $subject email subject
* @param string $messagetext text version of email
* @param string $messagehtml html version of email (will send both html and text)
* @param array $customheaders email headers
* @throws EmailException
* @throws EmailDisabledException
*/
function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml = '', $customheaders = null)
{
global $IDPJUMPURL;
static $mnetjumps = array();
if (!get_config('sendemail')) {
// You can entirely disable Mahara from sending any e-mail via the
// 'sendemail' configuration variable
return true;
}
if (empty($userto)) {
throw new InvalidArgumentException("empty user given to email_user");
}
if (!($mailinfo = can_receive_email($userto))) {
throw new EmailDisabledException("email for this user has been disabled");
}
// If the user is a remote xmlrpc user, trawl through the email text for URLs
// to our wwwroot and modify the url to direct the user's browser to login at
// their home site before hitting the link on this site
if (!empty($userto->mnethostwwwroot) && !empty($userto->mnethostapp)) {
require_once get_config('docroot') . 'auth/xmlrpc/lib.php';
// Form the request url to hit the idp's jump.php
if (isset($mnetjumps[$userto->mnethostwwwroot])) {
$IDPJUMPURL = $mnetjumps[$userto->mnethostwwwroot];
} else {
$mnetjumps[$userto->mnethostwwwroot] = $IDPJUMPURL = PluginAuthXmlrpc::get_jump_url_prefix($userto->mnethostwwwroot, $userto->mnethostapp);
}
$wwwroot = get_config('wwwroot');
$messagetext = preg_replace_callback('%(' . $wwwroot . '([\\w_:\\?=#&@/;.~-]*))%', 'localurl_to_jumpurl', $messagetext);
$messagehtml = preg_replace_callback('%href=["\'`](' . $wwwroot . '([\\w_:\\?=#&@/;.~-]*))["\'`]%', 'localurl_to_jumpurl', $messagehtml);
}
require_once 'phpmailer/class.phpmailer.php';
$mail = new phpmailer();
// Leaving this commented out - there's no reason for people to know this
//$mail->Version = 'Mahara ' . get_config('release');
$mail->PluginDir = get_config('libroot') . 'phpmailer/';
$mail->CharSet = 'UTF-8';
$smtphosts = get_config('smtphosts');
if ($smtphosts == 'qmail') {
// use Qmail system
$mail->IsQmail();
} else {
if (empty($smtphosts)) {
// use PHP mail() = sendmail
$mail->IsMail();
} else {
$mail->IsSMTP();
// use SMTP directly
$mail->Host = get_config('smtphosts');
if (get_config('smtpuser')) {
// Use SMTP authentication
$mail->SMTPAuth = true;
$mail->Username = get_config('smtpuser');
$mail->Password = get_config('smtppass');
}
}
}
if (get_config('bounces_handle') && isset($mailinfo->owner)) {
$mail->Sender = generate_email_processing_address($mailinfo->owner, $userto);
}
if (empty($userfrom) || $userfrom->email == get_config('noreplyaddress')) {
if (empty($mail->Sender)) {
$mail->Sender = get_config('noreplyaddress');
}
$mail->From = get_config('noreplyaddress');
$mail->FromName = isset($userfrom->id) ? display_name($userfrom, $userto) : get_config('sitename');
$customheaders[] = 'Precedence: Bulk';
// Try to avoid pesky out of office responses
$messagetext .= "\n\n" . get_string('pleasedonotreplytothismessage') . "\n";
if ($messagehtml) {
$messagehtml .= "\n\n<p>" . get_string('pleasedonotreplytothismessage') . "</p>\n";
}
} else {
if (empty($mail->Sender)) {
$mail->Sender = $userfrom->email;
}
$mail->From = $userfrom->email;
$mail->FromName = display_name($userfrom, $userto);
}
$replytoset = false;
if (!empty($customheaders) && is_array($customheaders)) {
foreach ($customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
if (0 === stripos($customheader, 'reply-to')) {
$replytoset = true;
}
}
}
if (!$replytoset) {
//.........这里部分代码省略.........
示例3: phpmailer
echo "<table><tr><td><small> --<br> To unsubscribe our newsletter, goto your profile<br>\n";
echo " {$url_to_start}/members.php?choice=myprofile<br>\n";
echo " remove the newsletter-checkbox and click the [Update] Button.<br></small></td></tr></table>\n";
}
if ($action == "send_newsletter") {
$count = 0;
$count2 = 0;
require "../library_mail.php";
$mail = new phpmailer();
$subject = stripslashes(urldecode($subject));
$body = stripslashes(urldecode($body));
$mail->From = "{$from}";
$mail->FromName = "{$bazar_name}";
# $mail->WordWrap = 75;
$mail->UseMSMailHeaders = true;
$mail->AddCustomHeader("X-Mailer: {$bazar_name} {$bazar_}#{$Id}\$- Email Interface");
$mail->Subject = $subject;
$mail->Body = $body;
if ($html) {
$mail->IsHTML(true);
}
if (function_exists("ini_get")) {
$upl_tmp_dir = ini_get('upload_tmp_dir');
} else {
$upl_tmp_dir = get_cfg_var('upload_tmp_dir');
}
if ($fix_tmp_dir) {
// only for fixing on some servers, normally NOT used - set in config.php
$tmp_dir = $fix_tmp_dir;
} elseif ($upl_tmp_dir) {
$tmp_dir = $upl_tmp_dir;
示例4: email_to_user
//.........这里部分代码省略.........
if (!empty($CFG->handlebounces)) {
$modargs = 'B' . base64_encode(pack('V', $user->id)) . substr(md5($user->email), 0, 16);
$mail->Sender = generate_email_processing_address(0, $modargs);
} else {
$mail->Sender = $supportuser->email;
}
if (is_string($from)) {
// So we can pass whatever we want if there is need
$mail->From = $CFG->noreplyaddress;
$mail->FromName = $from;
} else {
if ($usetrueaddress and $from->maildisplay) {
$mail->From = $from->email;
$mail->FromName = fullname($from);
} else {
$mail->From = $CFG->noreplyaddress;
$mail->FromName = fullname($from);
if (empty($replyto)) {
$mail->AddReplyTo($CFG->noreplyaddress, get_string('noreplyname'));
}
}
}
if (!empty($replyto)) {
$mail->AddReplyTo($replyto, $replytoname);
}
$mail->Subject = substr(stripslashes($subject), 0, 900);
$mail->AddAddress($user->email, fullname($user));
$mail->WordWrap = 79;
// set word wrap
if (!empty($from->customheaders)) {
// Add custom headers
if (is_array($from->customheaders)) {
foreach ($from->customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
}
} else {
$mail->AddCustomHeader($from->customheaders);
}
}
if (!empty($from->priority)) {
$mail->Priority = $from->priority;
}
if ($messagehtml && $user->mailformat == 1) {
// Don't ever send HTML to users who don't want it
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
// Encoding to use
$mail->Body = $messagehtml;
$mail->AltBody = "\n{$messagetext}\n";
} else {
$mail->IsHTML(false);
$mail->Body = "\n{$messagetext}\n";
}
if ($attachment && $attachname) {
if (ereg("\\.\\.", $attachment)) {
// Security check for ".." in dir path
$mail->AddAddress($supportuser->email, fullname($supportuser, true));
$mail->AddStringAttachment('Error in attachment. User attempted to attach a filename with a unsafe name.', 'error.txt', '8bit', 'text/plain');
} else {
require_once $CFG->libdir . '/filelib.php';
$mimetype = mimeinfo('type', $attachname);
$mail->AddAttachment($CFG->dataroot . '/' . $attachment, $attachname, 'base64', $mimetype);
}
}
/// If we are running under Unicode and sitemailcharset or allowusermailcharset are set, convert the email
/// encoding to the specified one
示例5: email_user
/**
* Always use this function for all emails to users
*
* @param object $userto user object to send email to. must contain firstname,lastname,preferredname,email
* @param object $userfrom user object to send email from. If null, email will come from mahara
* @param string $subject email subject
* @param string $messagetext text version of email
* @param string $messagehtml html version of email (will send both html and text)
* @param array $customheaders email headers
* @throws EmailException
*/
function email_user($userto, $userfrom, $subject, $messagetext, $messagehtml = '', $customheaders = null)
{
if (!get_config('sendemail')) {
// You can entirely disable Mahara from sending any e-mail via the
// 'sendemail' configuration variable
return true;
}
if (empty($userto)) {
throw new InvalidArgumentException("empty user given to email_user");
}
require_once 'phpmailer/class.phpmailer.php';
$mail = new phpmailer();
// Leaving this commented out - there's no reason for people to know this
//$mail->Version = 'Mahara ' . get_config('release');
$mail->PluginDir = get_config('libroot') . 'phpmailer/';
$mail->CharSet = 'UTF-8';
$smtphosts = get_config('smtphosts');
if ($smtphosts == 'qmail') {
// use Qmail system
$mail->IsQmail();
} else {
if (empty($smtphosts)) {
// use PHP mail() = sendmail
$mail->IsMail();
} else {
$mail->IsSMTP();
// use SMTP directly
$mail->Host = get_config('smtphosts');
if (get_config('smtpuser')) {
// Use SMTP authentication
$mail->SMTPAuth = true;
$mail->Username = get_config('smtpuser');
$mail->Password = get_config('smtppass');
}
}
}
if (empty($userfrom)) {
$mail->Sender = get_config('noreplyaddress');
$mail->From = $mail->Sender;
$mail->FromName = get_string('emailname');
$customheaders[] = 'Precedence: Bulk';
// Try to avoid pesky out of office responses
$messagetext .= "\n\n" . get_string('pleasedonotreplytothismessage') . "\n";
if ($messagehtml) {
$messagehtml .= "\n\n<p>" . get_string('pleasedonotreplytothismessage') . "</p>\n";
}
} else {
$mail->Sender = $userfrom->email;
$mail->From = $mail->Sender;
$mail->FromName = display_name($userfrom, $userto);
}
$replytoset = false;
if (!empty($customheaders) && is_array($customheaders)) {
foreach ($customheaders as $customheader) {
$mail->AddCustomHeader($customheader);
if (0 === stripos($customheader, 'reply-to')) {
$replytoset = true;
}
}
}
if (!$replytoset) {
$mail->AddReplyTo($mail->From, $mail->FromName);
}
$mail->Subject = substr(stripslashes($subject), 0, 900);
if ($to = get_config('sendallemailto')) {
// Admins can configure the system to send all email to a given address
// instead of whoever would receive it, useful for debugging.
$mail->addAddress($to);
$notice = get_string('debugemail', 'mahara', display_name($userto, $userto), $userto->email);
$messagetext = $notice . "\n\n" . $messagetext;
if ($messagehtml) {
$messagehtml = '<p>' . hsc($notice) . '</p>' . $messagehtml;
}
} else {
$usertoname = display_name($userto, $userto);
$mail->AddAddress($userto->email, $usertoname);
}
$mail->WordWrap = 79;
if ($messagehtml) {
$mail->IsHTML(true);
$mail->Encoding = 'quoted-printable';
$mail->Body = $messagehtml;
$mail->AltBody = $messagetext;
} else {
$mail->IsHTML(false);
$mail->Body = $messagetext;
}
if ($mail->Send()) {
return true;
//.........这里部分代码省略.........