【发布时间】:2017-01-24 05:56:09
【问题描述】:
我正在尝试在提交表单时发送电子邮件。我正在使用 PHPMailer 使用以下配置发送邮件。
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host = 'mail.example.in';
$mail->Port = 25;
$mail->SMTPAuth = true;
$mail->Username = 'user@example.in';
$mail->Password = 'password';
$mail->setFrom("user@example.in" , "User");
$mail->addAddress('receiver@example.in', 'Receiver');
$mail->addBCC('anotheruser@somedomain.com', 'Another user');
$mail->AddReplyTo('user@example.in', 'User');
$mail->isHTML(true);
$mail->Subject = $subject;
$mail->Body = $message;
if($mail->send())
echo "Your request has been received. We will soon contact you.";
else echo "Unable to send your request. Please try again";
这在 localhost 中运行良好。但是,当我将它部署到我的服务器(example.in)时,我得到了以下异常。
SMTP ERROR: Failed to connect to server: Connection timed out (110)
SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
--编辑--
我尝试使用 telnet 命令连接到 SMTP 服务器,但无法添加收件人。我收到以下错误?
Last login: Fri Sep 16 11:08:06 on ttys000
admin:~ admin$ telnet mail.example.in 25
Trying 111.91.153.112...
Connected to mail.example.in.
Escape character is '^]'.
220 fbs-ho-mailserver.example.in ESMTP Service (Lotus Domino Release 8.5.3FP3) ready at Fri, 16 Sep 2016 11:36:01 +0530
HELO example.in
250 fbs-ho-mailserver.example.in Hello example.in ([111.91.127.222]), pleased to meet you
MAIL from: marketing@example.in
250 marketing@example.in... Sender OK
RCPT to: john.hh@gmail.com
554 Relay rejected for policy reasons.
-- 编辑--
我能够在 Outlook 中设置此帐户。我真的很困惑发生了什么。
【问题讨论】:
-
听起来您的生产环境阻止了到邮件服务器的传出连接,或者邮件服务器阻止了传入连接。与运营人员交谈。
-
我认为 mail.example.in 不是有效的 smtp 服务器。
-
我添加了 mail.example.in 因为我不想透露实际的 smtp 服务器名称。
-
@Joni 没有运维人员。只有我。你能告诉我我需要做什么的步骤吗?
-
谁负责确保两台服务器也能正常运行?