How to use Zend_Mail_Transport_Smtp with hosted Google Apps?
Asked Answered
C

2

9

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?

Califate answered 10/4, 2009 at 7:30 Comment(2)
You could provide an error message.Saskatoon
Code looks OK, do you get an error message/exception?Caerphilly
C
13

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);
Califate answered 13/4, 2009 at 7:24 Comment(0)
C
2

Some more reference. Check the port using port scanner on remote end which are open, do a test if they reply packets, sometimes port 25 is not working so email fails, and also the SSL or TLS.

$config = array(
  'ssl' => 'ssl', //TLS = tcp://    use port 25      
                  //SSL = ssl://    use port 465 or 587
  'port' => 465,
  'auth' => 'login',
  'username'=> 'x',
  'password'=> 'b/c',
);
$tr = new Zend_Mail_Transport_Smtp('email-smtp.us-east-1.amazonaws.com', $config);
Zend_Mail::setDefaultTransport($tr);
Chamorro answered 31/10, 2012 at 12:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.