functions_email.php
来自「Zen Cart是真正的电子商务艺术」· PHP 代码 · 共 301 行 · 第 1/2 页
PHP
301 行
if ($module == 'xml_record') {
$email_html = '';
$customers_email_format =='TEXT';
}
//notifier intercept option
$zco_notifier->notify('NOTIFY_EMAIL_AFTER_EMAIL_FORMAT_DETERMINED');
// now lets build the mail object with the phpmailer class
$mail = & new PHPMailer();
$lang_code = strtolower(($_SESSION['languages_code'] == '' ? 'en' : $_SESSION['languages_code'] ));
$mail->SetLanguage($lang_code, DIR_FS_CATALOG . DIR_WS_CLASSES . 'support/');
$mail->CharSet = (defined('CHARSET')) ? CHARSET : "UTF-8";
$mail->Encoding = (defined('EMAIL_ENCODING_METHOD')) ? EMAIL_ENCODING_METHOD : "7bit";
if ((int)EMAIL_SYSTEM_DEBUG > 0 ) $mail->SMTPDebug = (int)EMAIL_SYSTEM_DEBUG;
$mail->WordWrap = 76; // set word wrap to 76 characters
// set proper line-endings based on switch ... important for windows vs linux hosts:
$mail->LE = (EMAIL_LINEFEED == 'CRLF') ? "\r\n" : "\n";
switch (EMAIL_TRANSPORT) {
case 'smtp':
$mail->IsSMTP();
$mail->Host = trim(EMAIL_SMTPAUTH_MAIL_SERVER);
if (EMAIL_SMTPAUTH_MAIL_SERVER_PORT != '25' && EMAIL_SMTPAUTH_MAIL_SERVER_PORT != '') $mail->Port = trim(EMAIL_SMTPAUTH_MAIL_SERVER_PORT);
$mail->LE = "\r\n";
break;
case 'smtpauth':
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Username = (zen_not_null(EMAIL_SMTPAUTH_MAILBOX)) ? trim(EMAIL_SMTPAUTH_MAILBOX) : EMAIL_FROM;
$mail->Password = trim(EMAIL_SMTPAUTH_PASSWORD);
$mail->Host = trim(EMAIL_SMTPAUTH_MAIL_SERVER);
if (EMAIL_SMTPAUTH_MAIL_SERVER_PORT != '25' && EMAIL_SMTPAUTH_MAIL_SERVER_PORT != '') $mail->Port = trim(EMAIL_SMTPAUTH_MAIL_SERVER_PORT);
$mail->LE = "\r\n";
//set encryption protocol to allow support for Gmail
if (EMAIL_SMTPAUTH_MAIL_SERVER_PORT == '465' && EMAIL_SMTPAUTH_MAIL_SERVER == 'smtp.gmail.com') $mail->Protocol = 'ssl';
if (defined('SMTPAUTH_EMAIL_PROTOCOL') && SMTPAUTH_EMAIL_PROTOCOL != 'none') {
$mail->Protocol = SMTPAUTH_EMAIL_PROTOCOL;
if (SMTPAUTH_EMAIL_PROTOCOL == 'starttls'){
$mail->Starttls = true;
$mail->Context = $Email_Certificate_Context;
}
}
break;
case 'PHP':
$mail->IsMail();
break;
case 'Qmail':
$mail->IsQmail();
break;
case 'sendmail':
case 'sendmail-f':
$mail->LE = "\n";
default:
$mail->IsSendmail();
if (defined('EMAIL_SENDMAIL_PATH')) $mail->Sendmail = trim(EMAIL_SENDMAIL_PATH);
break;
}
$mail->Subject = $email_subject;
$mail->From = $from_email_address;
$mail->FromName = $from_email_name;
$mail->AddAddress($to_email_address, $to_name);
// $mail->AddAddress($to_email_address); // (alternate format if no name, since name is optional)
// set the reply-to address. If none set yet, then use Store's default email name/address.
// If sending from contact-us or tell-a-friend page, use the supplied info
$email_reply_to_address = ($email_reply_to_address) ? $email_reply_to_address : (in_array($module, array('contact_us', 'tell_a_friend')) ? $from_email_address : EMAIL_FROM);
$email_reply_to_name = ($email_reply_to_name) ? $email_reply_to_name : (in_array($module, array('contact_us', 'tell_a_friend')) ? $from_email_name : STORE_NAME);
$mail->AddReplyTo($email_reply_to_address, $email_reply_to_name);
// if mailserver requires that all outgoing mail must go "from" an email address matching domain on server, set it to store address
if (EMAIL_SEND_MUST_BE_STORE=='Yes') $mail->From = EMAIL_FROM;
if (EMAIL_TRANSPORT=='sendmail-f' || EMAIL_SEND_MUST_BE_STORE=='Yes') {
$mail->Sender = EMAIL_FROM;
}
// PROCESS FILE ATTACHMENTS
if ($attachments_list == '') $attachments_list = array();
if (is_string($attachments_list)) {
if (file_exists($attachments_list)) {
$attachments_list = array(array('file' => $attachments_list));
} elseif (file_exists(DIR_FS_CATALOG . $attachments_list)) {
$attachments_list = array(array('file' => DIR_FS_CATALOG . $attachments_list));
} else {
$attachments_list = array();
}
}
$zco_notifier->notify('NOTIFY_EMAIL_BEFORE_PROCESS_ATTACHMENTS', $attachments_list);
if (defined('EMAIL_ATTACHMENTS_ENABLED') && EMAIL_ATTACHMENTS_ENABLED && is_array($attachments_list) && sizeof($attachments_list) > 0) {
foreach($attachments_list as $key => $val) {
$fname = (isset($val['name']) ? $val['name'] : null);
$mimeType = (isset($val['mime_type']) && $val['mime_type'] != '' && $val['mime_type'] != 'application/octet-stream') ? $val['mime_type'] : '';
switch (true) {
case (isset($val['raw_data']) && $val['raw_data'] != ''):
$fdata = $val['raw_data'];
if ($mimeType != '') {
$mail->AddStringAttachment($fdata, $fname, "base64", $mimeType);
} else {
$mail->AddStringAttachment($fdata, $fname);
}
break;
case (file_exists($val['file'])): //'file' portion must contain the full path to the file to be attached
$fdata = $val['file'];
if ($mimeType != '') {
$mail->AddAttachment($fdata, $fname, "base64", $mimeType);
} else {
$mail->AddAttachment($fdata, $fname);
}
break;
} // end switch
} //end foreach attachments_list
} //endif attachments_enabled
$zco_notifier->notify('NOTIFY_EMAIL_AFTER_PROCESS_ATTACHMENTS', sizeof($attachments_list));
// prepare content sections:
if (EMAIL_USE_HTML == 'true' && trim($email_html) != '' &&
($customers_email_format == 'HTML' || (ADMIN_EXTRA_EMAIL_FORMAT != 'TEXT' && substr($module,-6)=='_extra'))) {
$mail->IsHTML(true); // set email format to HTML
$mail->Body = $email_html; // HTML-content of message
$mail->AltBody = $text; // text-only content of message
} else { // use only text portion if not HTML-formatted
$mail->Body = $text; // text-only content of message
}
/**
* Send the email. If an error occurs, trap it and display it in the messageStack
*/
$ErrorInfo = '';
$zco_notifier->notify('NOTIFY_EMAIL_READY_TO_SEND');
if (!($result = $mail->Send())) {
if (IS_ADMIN_FLAG === true) {
$messageStack->add_session(sprintf(EMAIL_SEND_FAILED . ' '. $mail->ErrorInfo, $to_name, $to_email_address, $email_subject),'error');
} else {
$messageStack->add('header',sprintf(EMAIL_SEND_FAILED . ' '. $mail->ErrorInfo, $to_name, $to_email_address, $email_subject),'error');
}
$ErrorInfo .= $mail->ErrorInfo . '<br />';
}
$zco_notifier->notify('NOTIFY_EMAIL_AFTER_SEND');
// Archive this message to storage log
// don't archive pwd-resets and CC numbers
if (EMAIL_ARCHIVE == 'true' && $module != 'password_forgotten_admin' && $module != 'cc_middle_digs' && $module != 'no_archive') {
zen_mail_archive_write($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject, $email_html, $text, $module, $ErrorInfo );
} // endif archiving
} // end foreach loop thru possible multiple email addresses
$zco_notifier->notify('NOTIFY_EMAIL_AFTER_SEND_ALL_SPECIFIED_ADDRESSES');
if (EMAIL_FRIENDLY_ERRORS=='false' && $ErrorInfo != '') die('<br /><br />鐢靛瓙閭
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?