简体   繁体   中英

PHPMailer SMTP Failed to connect to server: Connection timed out (110) to Gmail

Im using PHPMailer to connect to Gmails MX server, gmail-smtp-in.l.google.com , on port 465 . This errors out Failed to connect to server: Connection timed out (110)

After reading online, I just had a chat with my host who successfully ran a traceroute to gmail-smtp-in.l.google.com on port 25 and I was assured that connections were not being blocked by anything on the host side.

Do I need to set up anything in my gmail account? I am able to connect to other domains via SMTP.


I can ALSO connect to smtp.gmail.com on 465 , but there the following command does not seem to work right

RCPT TO: <wrong.email@gmail.com>

gives me a 250 ok.

EDIT: and im using dns_get_record() to get MX record for domains.

this is part of the extended PHPMailer class that i wrote:

$this->IsSMTP(); 
$this->Host       = $this->data['smtp_host'];
$this->Mailer   = "smtp";
$this->Timeout      = 10;
$this->SMTPDebug  = 2;
$this->SMTPAuth   = true;
$this->Port       = 465;
$this->Username   = 'my.address@gmail.com';
$this->Password   = 'my_password';

$ret[] = $this->smtpConnect();
$ret[] = $this->smtp->mail('my.address@gmail.com');
$ret[] = $this->smtp->recipient('wrong.email@gmail.com');
$this->smtpClose();

the above on ssl://gmail-smtp-in.l.google.com:465 errors out with Connection timed out (110)

on ssl://smtp.gmail.com:465 says 250 Ok, where I should get no such user.

It's not clear why you are doing this. If you are using gmail's MX, it means you're sending directly to a gmail user. Typically this will only be on port 25, but if you want encryption, just issue a STARTTLS after connecting. SSL on 465 and TLS on 587 are submission ports for outbound mail, so I'm not surprised you get an immediate 250 OK - you'd expect a 5.1.1 bounce later on. If you tried the same on the MX, I would expect it to fail up front.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM