Resolved MSMTP - 554 error from Ionos

jrolland

New Pleskian
Server operating system version
Debian 12.14
Plesk version and microupdate number
18.0.78 #1
Hello!

I'm having a problem when a Cron job needs to send an email notification via the external SMTP relay (MSMTP).

When I test it via SSH using the following command, I don't encounter any issues:
Code:
echo -e "Subject: SMTP config confirmation\n\nEmail to confirm the SMTP configuration in MSMTP." | msmtp --debug [email protected] [email protected]
And this is what appears in /var/log/maillog:

May 21 00:50:07 serverName msmtp: host=smtp.ionos.fr tls=on auth=on user=[email protected] from=[email protected] recipients=[email protected] mailsize=202 smtpstatus=250 smtpmsg='250 Requested mail action okay, completed: id=1Mrh9Y-1xBDiN11qW-00h4I6' exitcode=EX_OK

But when the Cron job needs to send its notification, this is what appears in the same log:

May 21 01:11:06 serverName msmtp: host=smtp.ionos.fr tls=on auth=on user=[email protected] from=[email protected] recipients=[email protected] smtpstatus=554 smtpmsg='554-Transaction failed\n554-Reject due to policy restrictions.\n554 For explanation visit https://www.ionos.com/help/index.php?id=2425... errormsg='the server did not accept the mail' exitcode=EX_UNAVAILABLE

According to Ionos (https://www.ionos.com/help/index.php?id=2425#c138273), this is apparently due to the email being sent in the wrong format:

554 Transaction failed, reject due to policy restrictions​

Problem:

The email was rejected by the IONOS SMTP server because the standards defined in RFC 5321 and RFC 5322 were not adhered to.

Solution:

The email client must meet the following criteria:

  • The header lines of the email must contain exactly one valid "Date" line according to RFC 2822.
  • The following header lines may only exist once: From, Sender, To, CC, Subject
  • The header lines mentioned must be syntactically correct
Note: The To and CC lines can contain multiple recipients.

Is there anything I can do to fix this?
 
Thank you @Sebahat.hadzhi!

The idea of specifying the sender's address is brilliant.

I wasn't able to use the parameter you suggested adding.

When setting up a Cron Job, I need to set the environment variable MAILFROM="", immediately after defining MAILTO="", for it to work.

Code:
MAILTO="[email protected]"
MAILFROM="[email protected]"
16      12      *       *       *       echo "Test"

This post can now be closed if necessary.
 
Back
Top