我正在尝试使用 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的同事核实过“from email”是否真的被验证过了。它是:
我不知道要看什么或去哪里..
谢谢 :)
最佳答案
发生此错误是因为 SES 在沙盒中。在 Sandbox 中时,必须验证发件人和收件人的电子邮件,而不仅仅是发件人。
关于Codeigniter 和亚马逊 SES : error 554,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33666912/