Problem/Motivation
In Drupal 9.2.9 using SMTP version (1.0.0) when I try to connect to Amazon SES and try to programmatically send mail, I get the following error. Sending a SMTP test mail works fine from Drupal admin.
Error log - Error sending e-mail from xxxx to xxx@gmail.com: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: Transaction failed: Expected ';', got "\" SMTP code: 554
2022-02-02 06:17:37 CLIENT -> SERVER: X-Mailer: PHPMailer 6.5.3 (https://github.com/PHPMailer/PHPMailer)
2022-02-02 06:17:37 CLIENT -> SERVER: Sender: xxxxxxxxx
2022-02-02 06:17:37 CLIENT -> SERVER: MIME-Version: 1.0
2022-02-02 06:17:37 CLIENT -> SERVER: Content-Type: text/html; charset=utf-8\n
2022-02-02 06:17:37 CLIENT -> SERVER: Content-Transfer-Encoding: 8Bit
2022-02-02 06:17:37 CLIENT -> SERVER:
2022-02-02 06:17:37 CLIENT -> SERVER: This is test message
2022-02-02 06:17:37 CLIENT -> SERVER:
2022-02-02 06:17:37 CLIENT -> SERVER:
2022-02-02 06:17:37 CLIENT -> SERVER: .
2022-02-02 06:17:37 SMTP INBOUND: "554 Transaction failed: Expected ';', got "\""
2022-02-02 06:17:37 SERVER -> CLIENT: 554 Transaction failed: Expected ';', got "\"
2022-02-02 06:17:37 SMTP ERROR: DATA END command failed: 554 Transaction failed: Expected ';', got "\"
SMTP Error: data not accepted.
This is code I am using.
$mail_manager = \Drupal::service('plugin.manager.mail');
$result = $mail_manager->mail($module_name, $key, $recipients, $langcode, $params, $reply, true);
Steps to reproduce
This is the SMTP configuration.
- SMTP port: 587
- Use TLS
- Timeout: 30
Comments
Comment #2
avpadernoBugs are first fixed on the 9.4.x branch; eventually, the fix is back-ported.
Comment #3
avpadernoIn a plain Drupal installation, the class used to send emails is
PhpMail, which uses themail()function implemented by PHP to send emails, not the PHPMailer library.It seems you are using the PHPMailer SMTP module.
Comment #4
avpadernoThe code that could cause that issue is in
PhpMailerSmtp::mail(), but since it usestrim(), it removes any trailing new line character.Comment #5
imclean commentedI think this is the SMTP Auth module, which also uses the PHPMailer library.
Comment #6
imclean commentedBut in response to #4, I don't think the
trim()is a problem. The properties are used by the PHPMailer library which adds the appropriate separators or newlines as required.Comment #7
imclean commentedI misread #4. Ignore my comment #6.
Comment #8
bluegeek9 commentedComment #10
bluegeek9 commented