0
I started using phpmailer by the very example of the git page, it gives everything ok, echo goes to "message sent", but the message does not arrive in the email box, someone can say why?
<?php
require './PHPMailer/src/Exception.php';
require './PHPMailer/src/PHPMailer.php';
require './PHPMailer/src/SMTP.php';
$mail = new PHPMailer\PHPMailer\PHPMailer();
try {
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->SMTPSecure = 'tls';
$mail->Username = '[email protected]';
$mail->Password = '******';
$mail->Port = 587;
$mail->setFrom('[email protected]', 'Cairo');
$mail->addAddress('[email protected]', 'Yara');
$mail->addReplyTo('[email protected]', 'Information');
$mail->addCC('[email protected]');
$mail->addBCC('[email protected]');
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message enviada';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>
And in the spam box?
– Woss
also not arrived
– Cairoodev
has something to do with being on a local server? and not within a hosting
– Cairoodev
Take a look at the inbox of the sender email and see if it returned anything.
– Sam
returned nothing bro
– Cairoodev
There is a place in google that you have to give permission to apps to access your account. I just can’t remember now where it is.
– Sam
This one right here @Sam? Allow less secure apps to use your account and Allow less secure apps to use your account(Administrator)
– Augusto Vasques