0

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

Flex60460
  • 933
  • 2
  • 18
  • 49
  • I assume you removed the username and password for the purpose of this question and they are there in the code? Also, do you get any error at all in your error log or any entry in your general log? – Technoh Nov 03 '20 at 21:15
  • No I'm not remove username and password. Indeed we can use this smtp without authentification. It works well if the script is executing on localhost no error in this cas and no error if I execute this script from a computer on the same local network. But in this case the email is not delivery even if the serveur said 'mail accepted for delivery' ! Best regards – Flex60460 Nov 04 '20 at 08:44

1 Answers1

1

First of all, you are running a really old version of PHPMailer which contains several major security holes, so before you do anything else, upgrade to the latest version.

Next, as you note, the mail server accepts the message successfully:

250 2.0.0 nx5z2300P15i9bJ03x5z8R mail accepted for delivery

So from this point onwards, your script has no further involvement or responsibility for what happens to the message.

The most likely explanation for this is that the message was sent, and is hiding in your spam folder.

If the message bounced, you should receive a message telling you so sent to your envelope sender address, which will be whatever address you set in setFrom().

It is also possible that Orange is simply losing your message. Their email server config is truly terrible, for example they don't even offer TLS on ports that are supposed to do so, and allow authentication without encryption:

telnet smtp.orange.fr 587                                                                                                      1 ↵  11142  10:31:25
Trying 193.252.22.84...
Connected to smtp.orange.fr.
Escape character is '^]'.
220 mwinf5d29 ME ESMTP server ready
EHLO localhost
250-mwinf5d29 hello [x.x.x.x], pleased to meet you
250-HELP
250-AUTH LOGIN PLAIN
250-SIZE 44000000
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 OK

This means that clients can be tricked into connecting to fake servers, credentials intercepted easily by anyone that can see your internet traffic, and it seems likely that this server could be used as a spam gateway. For such a popular service, this is shockingly bad.

I would raise a support ticket with Orange to get some help from them. This problem is nothing to do with your script.

Synchro
  • 35,538
  • 15
  • 81
  • 104