views:

637

answers:

2

Hi guys, I'm using the zend framework and have a script which sends emails. However my script send emails perfectly on my localhost but I keep getting a fatal error on my online server:

Fatal error: Uncaught exception 'Zend_Mail_Protocol_Exception' with message 'Connection refused' in ....

The stack trace pin points just my emailing code which is below:

$tr = new Zend_Mail_Transport_Smtp($smtp, $config);
$mail = new Zend_Mail();
$mail->setDefaultTransport($tr);
$mail->setFrom($from, $from_name);
$mail->addTo($one_email);
$mail->setSubject( $subject );
$mail->setBodyText($content);
$mail->send($tr);

Whats wrong here why is the connection being refused :(

+4  A: 

It looks likely that the SMTP server you are using is not accessible from your 'online server'. Are you passing in a username and password in $config? If not doing so may help (see below for syntax), but obviously it depends on the configuration of the SMTP server.

$config = array('auth' => 'login',
   'username' => 'smtpUsernameHere'),
   'password' => 'smtpPasswordHere')
);

I don't think this is a problem with your code.

William
A: 

Hmmmm after trying frantically for 2 days I found out my host had changed the smtp host without even informing any of their clients!

Its working now fine - I'm still real chipped off at the nonchalant behavior of my host and gave 'em a real ear bashing on this - thanks for the help though.

Ali