我们最近从使用主机imap服务器更改为Office365交换服务器。
除了我们的网站订单确认消息外,我们所有的电子邮件似乎都正常运行。
我们的网站在处理订单时使用PHP邮件功能,以向客户以及我们自己发送电子邮件:
tep_mail($order->customer['firstname'] . ' ' . $order->customer['lastname'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
// send emails to other people
if (SEND_EXTRA_ORDER_EMAILS_TO != '') {
tep_mail('', SEND_EXTRA_ORDER_EMAILS_TO, EMAIL_TEXT_SUBJECT, $email_order, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
}
客户仍在接收确认电子邮件,但是似乎有很大的时间延迟(大约需要10分钟才能通过gmail帐户进行测试),与切换到交换服务器之前一样,基本上可以立即收到。
但是我们的交换服务器从未收到SEND_EXTRA_ORDER_EMAILS_TO。
是否存在阻止以这种方式将电子邮件发送到交换服务器的东西?
这是tep_mail函数:
function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {
if (SEND_EMAILS != 'true') return false;
// Instantiate a new mail object
$message = new email(array('X-Mailer: osCommerce'));
// Build the text version
$text = strip_tags($email_text);
if (EMAIL_USE_HTML == 'true') {
$message->add_html($email_text, $text);
} else {
$message->add_text($text);
}
// Send message
$message->build_message();
$message->send($to_name, $to_email_address, $from_email_name, $from_email_address, $email_subject);
}
和发送功能:
function send($to_name, $to_addr, $from_name, $from_addr, $subject = '', $headers = '') {
if ((strstr($to_name, "\n") != false) || (strstr($to_name, "\r") != false)) {
return false;
}
if ((strstr($to_addr, "\n") != false) || (strstr($to_addr, "\r") != false)) {
return false;
}
if ((strstr($subject, "\n") != false) || (strstr($subject, "\r") != false)) {
return false;
}
if ((strstr($from_name, "\n") != false) || (strstr($from_name, "\r") != false)) {
return false;
}
if ((strstr($from_addr, "\n") != false) || (strstr($from_addr, "\r") != false)) {
return false;
}
$to = (($to_name != '') ? '"' . $to_name . '" <' . $to_addr . '>' : $to_addr);
$from = (($from_name != '') ? '"' . $from_name . '" <' . $from_addr . '>' : $from_addr);
if (is_string($headers)) {
$headers = explode($this->lf, trim($headers));
}
for ($i=0; $i<count($headers); $i++) {
if (is_array($headers[$i])) {
for ($j=0; $j<count($headers[$i]); $j++) {
if ($headers[$i][$j] != '') {
$xtra_headers[] = $headers[$i][$j];
}
}
}
if ($headers[$i] != '') {
$xtra_headers[] = $headers[$i];
}
}
if (!isset($xtra_headers)) {
$xtra_headers = array();
}
if (EMAIL_TRANSPORT == 'smtp') {
return mail($to_addr, $subject, $this->output, 'From: ' . $from . $this->lf . 'To: ' . $to . $this->lf . implode($this->lf, $this->headers) . $this->lf . implode($this->lf, $xtra_headers));
} else {
return mail($to, $subject, $this->output, 'From: '.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this->lf, $xtra_headers));
}
}
更新:使用另一个Gmail帐户作为“管理员”帐户即可。因此,交换服务器正在阻止接收邮件功能