How to use Zend_Mail_Transport_Smtp with hosted Google Apps?

Andrew picture Andrew · Apr 10, 2009 · Viewed 13.1k times · Source

So I'm under the impression that bad things will happen if I don't use Zend_Mail_Transport_Smtp when sending lots of emails. Problem is...I can't figure out how to set it up. I am using Google Apps hosted email for my domain. So to access my email, I go to mail.mydomain.com, which takes me to a google login page.

This is the code that I am using, but it's not working.

$config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => '[email protected]', 'password' => 'password');
$smtpConnection = new Zend_Mail_Transport_Smtp('mail.mydomain.com', $config);
  • Using "mail.mydomain.com" I get a "connection timed out" error (which makes me think its the wrong thing to use.
  • Using "smtp.mydomain.com" I get a "Could not open socket" error.

What am I doing wrong?

Answer

Andrew picture Andrew · Apr 13, 2009

Since you are sending emails through gmail, you should use "smtp.gmail.com" and not your domain.

$config = array('ssl' => 'tls', 'port' => 587, 'auth' => 'login', 'username' => '[email protected]', 'password' => 'password');
$smtpConnection = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $config);