PHP Developers Network
http://forums.devnetwork.net/

Are there anyway to auto-detect availability of SMTP server
http://forums.devnetwork.net/viewtopic.php?f=52&t=103299
Page 1 of 1

Author:  FrankHe [ Fri Jul 17, 2009 3:26 pm ]
Post subject:  Are there anyway to auto-detect availability of SMTP server

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.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/