My hosting provider sometimes changed the smtp server, either from localhost to particular SMTP server or from SMTP server to localhost. I want to use Swift_Connection_Multi to automatically adopt the working smtp server, but I found it can NOT change automatically, instead, it only select the first connection to send email.
So, are there anyway to always select the first working SMTP server? This is the function I am using
public static function getSwiftMailer(){
$conn0=new Swift_Connection_SMTP( sfConfig::get("app_smtp_server"), sfConfig::get("app_smtp_port"));
$conn0->setUsername(sfConfig::get("app_smtp_user"));
$conn0->setPassword(sfConfig::get("app_smtp_password"));
$connections[] = $conn0;
$conn1 = new Swift_Connection_SMTP("localhost");
$connections[] = $conn1;
return new Swift(new Swift_Connection_Multi($connections));
}
Thanks for your help.
Are there anyway to auto-detect availability of SMTP server
Moderators: Chris Corbyn, General Moderators