i ve been trying to test sending emails from php using the phpmailer class. my config is this:
require '../php/library/class.phpmailer.php';
require '../php/library/class.smtp.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2;
$mail->Debugoutput = 'html';
$mail->Host = 'smtp.gmail.com';
$mail->Port = 587;
$mail->SMTPSecure = 'ssl';
$mail->SMTPAuth = true;
$mail->Username = "anactual@email.com";
$mail->Password = "thepassword";
$mail->setFrom('existing@gmail.com', 'Real Name');
$mail->addAddress( $validEmail );
$mail->Subject = 'Confirmation Code';
$mail->msgHTML('Follow this link: <a href="http://test.com/confirm?code=' . $newAccount->confirmationCode . '">http://test.com/confirm?code=' . $newAccount->confirmationCode . '</a>');
$mail->AltBody = 'This is a plain-text message body with this link: http://test.com/confirm?code=' . $newAccount->confirmationCode;
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
}
However, things do not seem to work, and i just copy pasted the code from the gmail example. i ve searched the world wide web for the error output:
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.
but still can not find out wha't wrong. any help please?
UPDATE i have disabled the two step verification in gmail