在1and1主机上使用Codeigniter发送SMTP电子邮件

时间:2011-10-20 15:59:33

标签: email codeigniter smtp shared-hosting

我正在尝试通过我在1and1上托管的codeigniter网站上的SMTP发送电子邮件。我在本地工作时效果很好,但只要我从1and1主机上尝试它就会出错。

这是我的配置:

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'auth.smtp.1and1.fr'; //i'm in france and this is the SMTP server adress 1and1 gave me.
$config['smtp_port'] = 25;
$config['smtp_user'] = 'user@mydomain.com';
$config['smtp_pass'] = 'password';

这是错误:

The following SMTP error was encountered: 110 Connection timed out
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: //details about my message i removed
Unable to send data: .

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.

然后我尝试使用smtp.1and1.com而不是auth.smtp.1and1.fr。令人惊讶的是它有效,但执行需要30秒! (在我的本地主机上,它是即时的)。

有什么建议吗?

2 个答案:

答案 0 :(得分:0)

说说他们的支持。他们可能对港口有限制。或者使用sendmail。

答案 1 :(得分:0)

如果您的托管服务器和电子邮件服务器位于同一位置,则无需进行smtp身份验证。

因此请从配置文件中删除以下代码,将所有内容保留为默认值并执行您的功能。为我工作在这种情况下应该适合你。

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'auth.smtp.1and1.fr'; //i'm in france and this is the SMTP server adress 1and1 gave me.
$config['smtp_port'] = 25;
$config['smtp_user'] = 'user@mydomain.com';
$config['smtp_pass'] = 'password';