I need you help. Indeed, emails sent to recipients arrive only if the script is executed from the server. If the script is executing from remote client, no error to connect to SMTP server but the email never arrives. This problem exist only with a French smtp (smtp.orange.fr) Find below the script I used to test :
<?php
include('PHPMailer_v5.2.16/class.phpmailer.php');
include('PHPMailer_v5.2.16/class.smtp.php');
$mail = new PHPMailer(true); // Passing `true` enables exceptions
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.orange.fr'; // Specify main (and backup SMTP) servers (sÈparÈs par un point virgule)
$mail->SMTPAuth = false;
$mail->SMTPAutoTLS = false;
//$mail->SMTPAuth = false; // Enable SMTP authentication
//$mail->SMTPAuth = true;
$mail->Username = '';
$mail->Password = ''; // SMTP password
//$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
//$mail->SMTPSecure = 'tls'; //provoque une erreur de connexion
//$mail->SMTPSecure = 'ssl'; //provoque une erreur "SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting"
$mail->Port = 25; // TCP port to connect to
//$mail->Port = 465; // TCP port to connect to
$mail->setLanguage('fr', 'language/');
$mail->CharSet ='utf-8';
$mail->setFrom('exemplefrom@laposte.net', 'Exp');
$mail->addAddress('exempleto@laposte.net', 'Joe User');// Add a recipient
//Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Sujet du mail';
$mail->Body = 'corps du mail <b>en gras!</b>';
//OE
$mail->WordWrap = 0;
$mail->ContentType = 'text/html';
$mail->Encoding = '8bit';
$mail->send();
echo 'Le message a été envoye';
} catch (Exception $e) {
echo 'Message could not be sent. ';
echo 'Mailer Error: ' . $mail->ErrorInfo;
}
?>
In both case, from server or from client the debug is the same :
2020-11-03 21:06:07 SERVER -> CLIENT: 220 mwinf5d15 ME ESMTP server ready
2020-11-03 21:06:07 CLIENT -> SERVER: EHLO 127.0.0.1
2020-11-03 21:06:07 SERVER -> CLIENT: 250-mwinf5d15 hello [86.245.192.50], pleased to meet you
250-HELP
250-AUTH LOGIN PLAIN
250-SIZE 44000000
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 OK
2020-11-03 21:06:07 CLIENT -> SERVER: MAIL FROM:
2020-11-03 21:06:07 SERVER -> CLIENT: 250 2.1.0 sender ok
2020-11-03 21:06:07 CLIENT -> SERVER: RCPT TO:
2020-11-03 21:06:07 SERVER -> CLIENT: 250 2.1.5 recipient ok
2020-11-03 21:06:07 CLIENT -> SERVER: DATA
2020-11-03 21:06:07 SERVER -> CLIENT: 354 enter mail, end with "." on a line by itself
2020-11-03 21:06:07 CLIENT -> SERVER: Date: Tue, 3 Nov 2020 21:06:07 +0000
2020-11-03 21:06:07 CLIENT -> SERVER: To: Joe User
2020-11-03 21:06:07 CLIENT -> SERVER: From: Exp
2020-11-03 21:06:07 CLIENT -> SERVER: Subject: Sujet du mail
2020-11-03 21:06:07 CLIENT -> SERVER: Message-ID: <2671dcaa1642a1c676ea766b38c3ba5a@127.0.0.1>
2020-11-03 21:06:07 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.16 (https://github.com/PHPMailer/PHPMailer)
2020-11-03 21:06:07 CLIENT -> SERVER: MIME-Version: 1.0
2020-11-03 21:06:07 CLIENT -> SERVER: Content-Type: text/html; charset=utf-8
2020-11-03 21:06:07 CLIENT -> SERVER:
2020-11-03 21:06:07 CLIENT -> SERVER: corps du mail en gras!
2020-11-03 21:06:07 CLIENT -> SERVER:
2020-11-03 21:06:07 CLIENT -> SERVER: .
2020-11-03 21:06:07 SERVER -> CLIENT: 250 2.0.0 nx5z2300P15i9bJ03x5z8R mail accepted for delivery
2020-11-03 21:06:07 CLIENT -> SERVER: QUIT
2020-11-03 21:06:07 SERVER -> CLIENT: 221 2.0.0 mwinf5d15 ME closing connection Le message a été envoye
So could you help me to solve that. Best regards