I am trying to use PHPMailer to send an email. I am using the latest version (5.2.8) installed using Git. My PHP version is 5.5.11 and is running on Centos 6.4 with Apache 2.2. I am running the script provided under examples/gmail.php
(also available at http://phpmailer.worxware.com/index.php?pg=examplebgmail) except that I changed my username and password to my actual gmail credentials. My gmail credentials work with PHPMailer 5.0.0.
When running the script, I get the following error:
SMTP ERROR: Failed to connect to server: php_network_getaddresses: getaddrinfo failed: Name or service not known (0)
SMTP connect() failed.
Mailer Error: SMTP connect() failed.
If I run the script in my PhpED IDE, I get exception SMTP connection() failed
from line 1195 in class.phpmailer.php (line 1195 is shown below).
if (!$this->smtpConnect()) {
throw new phpmailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
}
Per earlier answer Connection error with PHPMailer and SMTP: node name or service name not known, I tried the following with the following results:
[root@devserver ~]# nslookup smtp.gmail.com
Server: 192.168.0.1
Address: 192.168.0.1#53
Non-authoritative answer:
smtp.gmail.com canonical name = gmail-smtp-msa.l.google.com.
Name: gmail-smtp-msa.l.google.com
Address: 173.194.79.108
Name: gmail-smtp-msa.l.google.com
Address: 173.194.79.109
[root@devserver ~]#
[Michael@devserver ~]$ ping smtp.gmail.com
PING gmail-smtp-msa.l.google.com (74.125.25.108) 56(84) bytes of data.
64 bytes from pa-in-f108.1e100.net (74.125.25.108): icmp_seq=1 ttl=47 time=18.6 ms
What is causing this error and how do I fix it? Thank you