Php 不能使用codeigniter使用邮枪smtp发送邮件

Php 不能使用codeigniter使用邮枪smtp发送邮件,php,codeigniter,mailgun,Php,Codeigniter,Mailgun,我正在尝试使用codeigniter电子邮件库和mailgun smtp发送电子邮件。 smtp设置配置正确,我不知道有什么问题 以下是php代码: $config['mailtype'] = 'html'; $config['charset'] = 'utf-8'; $config['protocol'] = 'smtp'; $config['smtp_host'] = 'smtp.mailgun.org'; $config['smtp_port'] = 25; $config['smtp_

我正在尝试使用codeigniter电子邮件库和mailgun smtp发送电子邮件。 smtp设置配置正确,我不知道有什么问题

以下是php代码:

$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.mailgun.org';
$config['smtp_port'] = 25;
$config['smtp_user'] = 'user@user.com';
$config['smtp_pass'] = 'thepasswordconfiguredinmailgun';
$config['smtp_timeout'] = '4';
$config['crlf'] = '\n';
$config['newline'] = '\r\n';

$this->email->initialize($config);
$this->email->clear(TRUE);
$this->email->from('office@test.com', 'FromName');
$this->email->to('myemail@yahoo.com');

$this->email->subject('Subiect de test');
$this->email->message('Testez sa vad daca merge si daca pot sa trimit. Daca nu pot de ce nu pot ?');

$this->email->send();
echo $this->email->print_debugger();
我有以下错误:

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: User-Agent: CodeIgniter Date: Fri, 13 May 2016 10:19:19 +0300 From: "PADigest" Return-Path: To: test123@yahoo.com Subject: =?utf-8?Q?Subiect_de_test?= Reply-To: "office@padiads.ro" X-Sender: office@padigest.ro X-Mailer: CodeIgniter X-Priority: 3 (Normal) Message-ID: <57357ff767c94@padiads.ro> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="B_ALT_57357ff767d02" This is a multi-part message in MIME format. Your email application may not support this format. --B_ALT_57357ff767d02 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Testez sa vad daca merge si daca pot sa trimit. Daca nu pot de ce nu pot ? --B_ALT_57357ff767d02 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable Testez sa vad daca merge si daca pot sa trimit. Daca nu pot de ce nu pot ? --B_ALT_57357ff767d02--
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.

User-Agent: CodeIgniter
Date: Fri, 13 May 2016 10:19:19 +0300
From: "PADigest" <office@padiast.ro>
Return-Path: <office@padiasr.ro>
To: test124@yahoo.com
Subject: =?utf-8?Q?Subiect_de_test?=
Reply-To: "office@padiast.ro" <office@padiast.ro>
X-Sender: office@padiast.ro
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <57357ff767c94@padigest.ro>
Mime-Version: 1.0


Content-Type: multipart/alternative; boundary="B_ALT_57357ff767d02"

This is a multi-part message in MIME format.
Your email application may not support this format.

--B_ALT_57357ff767d02
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Testez sa vad daca merge si daca pot sa trimit. Daca nu pot de ce nu pot ?


--B_ALT_57357ff767d02
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Testez sa vad daca merge si daca pot sa trimit. Daca nu pot de ce nu pot ?

--B_ALT_57357ff767d02--
遇到以下SMTP错误:110连接超时 无法发送数据:身份验证登录 无法发送AUTH LOGIN命令。错误: 无法发送数据:邮件发件人: 发件人: 遇到以下SMTP错误: 无法将数据:RCPT发送到: 致: 遇到以下SMTP错误: 无法发送数据:数据 数据: 遇到以下SMTP错误: 无法发送数据:用户代理:CodeIgniter日期:2016年5月13日星期五10:19:19+0300发件人:“PADigest”返回路径:收件人:test123@yahoo.com主题:=?utf-8?Q?子测试?=回复:office@padiads.ro“X-Sender:office@padigest.roX-Mailer:CodeIgniter X-Priority:3(正常)消息ID:Mime版本:1.0内容类型:多部分/可选;boundary=“B_ALT_57357ff767d02”这是一条MIME格式的多部分消息。您的电子邮件应用程序可能不支持此格式--B_ALT_57357ff767d02内容类型:文本/普通;字符集=utf-8内容传输编码:8比特测试sa vad daca merge si daca pot sa trimit。达卡努锅德西努锅--B_ALT_57357ff767d02内容类型:text/html;charset=utf-8内容传输编码:引用可打印的Testez sa vad daca merge si daca pot sa trimit。达卡努锅德西努锅--B_ALT_57357ff767d02-- 无法发送数据:。 遇到以下SMTP错误: 无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。 用户代理:CodeIgniter 日期:2016年5月13日星期五10:19:19+0300 来自:“帕迪吉斯特” 返回路径: 致:test124@yahoo.com 主题:=?utf-8?Q?子测试= 答复:office@padiast.ro" X-Sender:office@padiast.ro X-Mailer:CodeIgniter X优先级:3(正常) 消息ID: Mime版本:1.0 内容类型:多部分/备选;boundary=“B_ALT_57357ff767d02” 这是MIME格式的多部分消息。 您的电子邮件应用程序可能不支持此格式。 --B_ALT_57357ff767d02 内容类型:文本/纯文本;字符集=utf-8 内容传输编码:8比特 Testez sa vad daca merge si daca pot sa trimit。达卡努锅德西努锅? --B_ALT_57357ff767d02 内容类型:text/html;字符集=utf-8 内容传输编码:引用可打印 Testez sa vad daca merge si daca pot sa trimit。达卡努锅德西努锅? --B_ALT_57357ff767d02-- 通过检查:

大多数情况下,这是由互联网服务提供商(“ISP”)阻塞端口25造成的。如果您使用的是住宅ISP,则可能会发生这种情况

要检查此问题,请尝试在命令行中运行telnet:

telnet smtp.mailgun.org 25
如果端口25未被阻止,您应该看到如下内容:

Trying 174.37.214.195...
Connected to mxa.mailgun.org.
Escape character is '^]'.
220 mxa.mailgun.org (Mailgun)
如果您没有看到这一点,那么您将被阻止。有两种变通方法:

  • 使用HTTP API发送
  • 尝试使用端口587或2525

  • 问题是我的共享主机提供商。他们不接受与外部smtp邮件提供商的连接。不过,我会接受sotoz的答复,因为我将使用http api发送它们

    我认为港口没有堵塞。如果我尝试使用localhost作为smtp服务器,邮件会发送。由于使用共享主机,我无法访问终端,但我发送了一封电子邮件@hosting provider在控制台中编写命令。@florin您是否尝试过文档中所述的其他端口,如2525?