我尝试使用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的同事一起检查了电子邮件&#34;来自电子邮件&#34;真的得到了验证。它是:
我不知道该在哪里或在哪里看......
Thx:)
答案 0 :(得分:0)
发生此错误是因为SES位于Sandbox中。在Sandbox中,必须验证发件人和收件人电子邮件,而不仅仅是发件人。