Ik probeer een e-mail te versturen via GMail's SMTP server vanaf een PHP pagina, maar ik krijg deze foutmelding:
authenticatie mislukt [SMTP: SMTP server ondersteunt geen authenticatie (code: 250, response: mx.google.com at your service, [98.117.99.235] SIZE 35651584 8BITMIME STARTTLS ENHANCEDSTATUSCODES PIPELINING)]
Kan iemand helpen? Hier is mijn code:
<?php
require_once "Mail.php";
$from = "Sandra Sender <[email protected]>";
$to = "Ramona Recipient <[email protected]>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
$host = "smtp.gmail.com";
$port = "587";
$username = "[email protected]";
$password = "testtest";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("<p>Message successfully sent!</p>");
}
?>
Uw code lijkt geen gebruik te maken van TLS (SSL), wat nodig is om mail bij Google af te leveren (en poorten 465 of 587 te gebruiken).
U kunt dit doen door
$host = "ssl://smtp.gmail.com";
Je code lijkt verdacht veel op dit voorbeeld die verwijst naar ssl:// in het hostname schema.