Omdat ik als afzenderadres een Gmail-adres gebruik, raadt mijn provider me aan SMTP authentificatie toe te passen.
Al geruime tijd ben ik aan het googelen en testen van scripts, maar het wil niet lukken.
Bij het activeren van onderstaand script:
<?php
require_once('phpmailer/class.phpmailer.php');
$mail = new PHPMailer(true); // the true param means it will throw exceptions on errors, which we need to catch
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "tls"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 587; // set the SMTP port for the GMAIL server
$mail->Username = "[email protected]"; // GMAIL username
$mail->Password = "mypassword"; // GMAIL password
$mail->AddReplyTo('[email protected]', 'First Last');
$mail->AddAddress('[email protected]', 'John Doe');
$mail->SetFrom('[email protected]', 'First Last');
$mail->Subject = 'PHPMailer Test Subject via mail(), advanced';
$mail->AltBody = 'To view the message, please use an HTML compatible email viewer!';
$mail->Body = 'Message';
if ($mail->Send()){
echo "Message Sent";
}
else{
echo "Mailer Error: " . $mail->ErrorInfo;
}
?>
krijg ik de volgende melding:
SMTP -> FROM SERVER:220 smtp.gmail.com ESMTP d1sm9565623wjb.47 - gsmtp
SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [84.244.181.122] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8
SMTP -> FROM SERVER:220 2.0.0 Ready to start TLS
SMTP -> FROM SERVER: 250-smtp.gmail.com at your service, [84.244.181.122] 250-SIZE 35882577 250-8BITMIME 250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8
SMTP -> ERROR: Password not accepted from server: 534-5.7.14 Please log in via your web browser and 534-5.7.14 then try again. 534-5.7.14 Learn more at 534 5.7.14 https://support.google.com/mail/answer/78754 d1sm9565623wjb.47 - gsmtp
SMTP -> FROM SERVER:250 2.1.5 Flushed d1sm9565623wjb.47 - gsmtp
Ik hoop dat iemand een oplossing heeft.