使用phpmailer的后备smtp服务器 [英] Fallback smtp servers with phpmailer

查看:145
本文介绍了使用phpmailer的后备smtp服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用gmail作为phpmailer()的smtp服务器.

I'm using gmail as my smtp server with phpmailer().

$mail->Host= "ssl://smtp.gmail.com"

在与gmail的连接失败的情况下,如何作为备份来指定单独的smtp服务器?

How do i specify a separate smtp server just as a back up incase the connection to gmail fails ?

推荐答案

PHPMailer内置了不需要繁琐的工作.设置主机时,只需在以分号分隔的列表中添加多个主机(也可以同时指定安全设置),如下所示:

No need for all that hard work, it's built in to PHPMailer. When you set the host, just add more than one in a semicolon-delimited list (you can also specify security settings at the same time), like this:

$mail->Host = 'tls://smtp.gmail.com:587;tls://smtp2.gmail.com;ssl://mail.example.net:465';

在放弃之前,PHPMailer将按照提供的顺序尝试全部操作.确保您使用的是最新版本的PHPMailer,因为较早版本的该区域中存在错误.

PHPMailer will try them all, in the provided order, before giving up. Make sure you are using a fairly recent version of PHPMailer as there were bugs in this area in older versions.

这篇关于使用phpmailer的后备smtp服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆