我试图建立一个联系表,和我挣扎得到它与CI的SMTP配置工作。 不过,我已经成功地尝试了基本的“邮件”的配置。
长话短说,我做我的测试,这个简单的代码:
$config = array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.1and1.es',
'smtp_port' => 25,
'smtp_user' => 'user@mysite.com',
'smtp_pass' => '********',
'mailtype' => 'text',
'charset' => 'utf-8',
'wordwrap' => true,
'wrapchars' => 50
);
$this->load->library('email');
$this->email->initialize($config);
$this->email->from('my_real_email_address@gmail.com');
$this->email->to('my_real_email_address@gmail.com');
$this->email->reply_to('my_real_email_address@gmail.com', 'John Doe');
$this->email->subject('Message sent from the contact form in website');
$this->email->message('Body of message...');
if ($this->email->send()) {
return true;
}
echo '<!--' . print_r($this->email->print_debugger(), true) . '-->';
return false;
我刚刚问我的托管服务提供商和所有的SMTP配置是正确的。 他们还检查我的电子邮件帐户是否正常工作。
事实上,如果我选择:
协议>“邮件”
该消息是没有问题的交付。 据我所知PHP的mail()函数也使用托管服务提供商SMTP,但它只是将它交给服务器,而忘记它。
相反,我想使用SMTP认证,其担心电子邮件的发送。 但是,只有通过改变
协议=> 'SMTP'
当我发送的形式有很多的处理时间,我终于得到这个调试消息:
220 smtp.1and1.es (mreu2) Welcome to Nemesis ESMTP server
hello: The following SMTP error was encountered:
Failed to send AUTH LOGIN command. Error: 421 smtp.1and1.es connection timed out
from: The following SMTP error was encountered:
to: The following SMTP error was encountered:
data: The following SMTP error was encountered:
The following SMTP error was encountered:
Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Thu, 24 Jan 2013 18:51:31 +0100
From: <my_real_email_address@gmail.com>
Return-Path: <my_real_email_address@gmail.com>
To: my_real_email_address@gmail.com
Reply-To: "John Doe" <my_real_email_address@gmail.com>
Subject: =?utf-8?Q?Message_sent_from_the_contact_form_in_website?=
X-Sender: my_real_email_address@gmail.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <510174a33158d@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Body of message...
什么可能是这个错误的原因是什么?