Are there anyway to auto-detect availability of SMTP server

Swift Mailer is a fantastic library for sending email with php. Discuss this library or ask any questions about it here.

Moderators: Chris Corbyn, General Moderators

Post Reply
FrankHe
Forum Newbie
Posts: 5
Joined: Thu Jan 22, 2009 9:36 am

Are there anyway to auto-detect availability of SMTP server

Post by FrankHe »

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.
Post Reply