我正在尝试使用Code Igniter和Amazon SES作为smtp服务器发送电子邮件。这是我使用的代码:
public function test_mail()
{
$this->load->library('email');
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'email-smtp.eu-west-1.amazonaws.com',
'smtp_user' => 'my_smtp_user',
'smtp_pass' => 'my_smtp_pass',
'smtp_port' => 587,
'mailtype' => 'html',
'smtp_crypto' => 'tls'
);
$this->email->initialize($config);
$this->email->set_newline("\r\n");
$this->email->from('verified@email.com', 'Test From');
$this->email->to('my_email@email.com', 'Test To');
$this->email->subject('Test');
$this->email->message('test');
$this->email->send();
var_dump($this->email->print_debugger());
}
代码简单,但是无法运行。
我也尝试了许多主机/端口组合,但都没有成功 :(
以下是var_dump的结果:
220 email-smtp.amazonaws.com ESMTP SimpleEmailService-1207641145
hello: 250-email-smtp.amazonaws.com
250-8BITMIME
250-SIZE 10485760
250-STARTTLS
250-AUTH PLAIN LOGIN
250 Ok
starttls: 220 Ready to start TLS
hello: 250-email-smtp.amazonaws.com
250-8BITMIME
250-SIZE 10485760
250-STARTTLS
250-AUTH PLAIN LOGIN
250 Ok
from: 250 Ok
to: 250 Ok
data: 354 End data with .
554 Message rejected: Email address is not verified.
The following SMTP error was encountered: 554 Message rejected: Email address is not verified.
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Thu, 12 Nov 2015 07:57:17 +0000
From: "Test From" <verified@email.com>
Return-Path: <verified@email.com>
To: my_email@email.com
Subject: Test
Reply-To: "verified@email.com" <verified@email.com>
X-Sender: verified@email.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <5644465d8dad1@email.com>
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="B_ALT_5644465d8db88"
This is a multi-part message in MIME format.
Your email application may not support this format.
--B_ALT_5644465d8db88
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
test
--B_ALT_5644465d8db88
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
test
--B_ALT_5644465d8db88--
当然,在撰写这个问题之前,我与负责SES的同事核实了“发件人电子邮件地址”是否真实验证过。确实已经验证。
我不知道该做什么或者去哪里找...
谢谢 :)