CodeIgniter 2.1.4版本无法通过smtp发送邮件给办公室365

问题描述:

我试图使用CodeIgniter版本2.1.4为办公室365使用SMTP服务器发送电子邮件。我知道登录是正确的。以下是我的配置+调试器输出。CodeIgniter 2.1.4版本无法通过smtp发送邮件给办公室365

的application/config/email.php

<?php 
    $config['protocol'] = 'smtp'; 
    $config['smtp_host'] = 'tls://smtp.office365.com'; 
    $config['smtp_user'] = '[email protected]'; 
    $config['smtp_pass'] = 'PASSWORD'; 
    $config['smtp_port'] = '587'; 
    $config['charset']='utf-8'; 
    $config['newline']="\r\n"; 
    $config['crlf'] = "\r\n"; 
    ?> 

电子邮件调试错误:

The following SMTP error was encountered: 0 
Unable to send data: AUTH LOGIN 
Failed to send AUTH LOGIN command. Error: 
Unable to send data: MAIL FROM: 
from: 
The following SMTP error was encountered: 
Unable to send data: RCPT TO: 
to: 
The following SMTP error was encountered: 
Unable to send data: DATA 
data: 
The following SMTP error was encountered: 
Unable to send data: User-Agent: CodeIgniter Date: Mon, 6 Apr 2015 12:19:52 -0400 From: "PHP Point Of Sale, LLC" Return-Path: To: [email protected] Subject: =?utf-8?Q?Sales_Receipt?= Reply-To: "[email protected]" X-Sender: [email protected] X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <[email protected]> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_5522b228bf4b9" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_5522b228bf4b9 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit PHP Point Of Sale, LLC 123 Nowhere street 555-555-5555 Sales Receipt 04/06/2015 12:19 pm Customer: Chris Muench - Apple - 3333 Address : 6 Heron Way N Fairport NY, 14450-3318United States Phone Number : testE-Mail : [email protected] ID: POS 9 Register Name: Default Employee: John Doe Item Price Qty. Total TEST (Size) $12.00 1 $12.00 Sub Total $12.00 Total $12.00 Payment Type Cash $12.00 Change Due $0.00 Change return policy --B_ALT_5522b228bf4b9 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable 
+0

你应该升级到3.0笨最新版本 – user4419336

+0

我不知道CI电子邮件库支持(TLS | SSL)连接要求。您可能需要一个可以处理这些传输类型的库。 http://getsparks.org/packages/swift-mailer/versions/HEAD/show – Philip

+0

@ mustang83不幸的是,CI 3刚刚问世,需要进行相当数量的代码更改才能正常工作。我正在寻找CI 2修复程序。 –

虽然它在CI docs

没有提到有一个配置项称为smtp_crypto,你可以找到在系统库中的Email.php类中。 您的情况需要设置为tls

那么你的配置变得

$config['smtp_crypto']= 'tls'; 
$config['smtp_host'] = 'smtp.office365.com';