• The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Change cron mailfrom address

foxtrot

New Pleskian
Hi,
I installed Plesk on a machine where I have to use an external smtp server.

I have set a cron job via the interface at /user/scheduler/tasks-list.
The cron execute a command as root and send an email in case of errors.

The problem is that the mail sender address is set by plesk as "root (cron daemon)" and for this reason the mail is bounced when sent to a gmail address.

To be more specific gmail bounce the email with the following error message:

Our system has detected that this message is 550-5.7.1 not RFC 5322 compliant: 550-5.7.1 'From' header is missing. 550-5.7.1 To reduce the amount of spam sent to Gmail, this message has been 550-5.7.1 blocked.

How can I change the from address (in this case for the root user) and set it to something like [email protected]?


Thanks
 
I think that the messages that a cronjob generates are always sent on behalf of the job owner. So if root is executing the job, that's the one which will send the message.

If you want to circumvent this, you need to create your job in a way that it outputs all results to your own mail routine, e.g. something like

* * * * * /path/to/your_script 2>&1 | mail -s "Output of /path/to/script" [email protected] -- -r "[email protected]" -F"Sender name"

So instead of only /path/to/your_script you could try /path/to/your_script 2>&1 | mail -s "Output of /path/to/script" [email protected] -- -r "[email protected]" -F"Sender name". I have not tested that, it's just an idea.
 
Hi,

that doesn't seems to work.

Is it possible instead to set somehow the default mail address for root ?
 
root@<hostname>, that depends on what you've set as your hostname. It is not possible to give "root" different name than "root" in the first part of the mail address.
 
Is this what you're looking for?
I tried but didn't work for me. After I executed #crontab -e, added the line MAILFROM=[email protected] and now I do not receive any emails from Scheduled Tasks. I removed the MAILFROM=[email protected] and still cannot receive any emails where before at least I got them from root (cron deamon) when I fetched an URL.
 
Please compare your crontab file located in /var/spool/cron/<username> with this template example:
Code:
MAILTO="[email protected]"
SHELL="/bin/sh"
*/5     *       *       *       *       (/usr/local/psa/admin/sbin/fetch_url 'https://just-some.tld/cron.php')  > /dev/null
If the MAILTO line is formatted correctly and if the command line is valid, mails must be sent. If you do not see mails sent, check if there is a # in front of a line (there should be none) and also check what is logged in /var/log/maillog at the time when mails should be sent.
 
Mine looks like this...


MAILTO="[email protected]"
SHELL="/bin/sh"
30 1 * * * /usr/local/psa/admin/sbin/fetch_url 'Website Domain Names, Online Stores & Hosting - Domain.com'


its missing the parenthesis () and > /dev/null

when I tried to add the missing information I received a message, error writing to the file, permission denied.


Seems login as Administrator in Plesk and running #crontab -e adding the MAILFROM and removing it did something to my configuration.
 
Please compare your crontab file located in /var/spool/cron/<username> with this template example:
Code:
MAILTO="[email protected]"
SHELL="/bin/sh"
*/5     *       *       *       *       (/usr/local/psa/admin/sbin/fetch_url 'https://just-some.tld/cron.php')  > /dev/null
If the MAILTO line is formatted correctly and if the command line is valid, mails must be sent. If you do not see mails sent, check if there is a # in front of a line (there should be none) and also check what is logged in /var/log/maillog at the time when mails should be sent.
Hi Peter, Mails are being sent to the var/log/maillog, I receive the emails to [email protected] however the from email address is root (cron deamon) or invalid@invalid, even when the from email address in the var/log/maillog is from [email protected]

Mar 22 12:00:03 cp msmtp: host=smtp-relay.sendinblue.com tls=on auth=on user=[email protected] from=[email protected] recipients=[email protected] mailsize=72465 smtpstatus=250 smtpmsg='250 Message queued as <[email protected]>' exitcode=EX_OK

thank you for your help!
 
I see that on top of the question you have a special SMTP configuration where you are not using a local SMTP server. I am not sure whether your SMTP server transcribes the sender address or if the client does it, but one or the other probably do. From Apple users I have frequently seen that if the sender is listed in their address book, their mail software displays what is in the address book, not what is in the mail. Maybe it is a similar issue here? To examine this further I reccommend looking into the email headers of the received mail to see what sender address is listed on the first hop and if that is changed later on.
 
I see that on top of the question you have a special SMTP configuration where you are not using a local SMTP server. I am not sure whether your SMTP server transcribes the sender address or if the client does it, but one or the other probably do. From Apple users I have frequently seen that if the sender is listed in their address book, their mail software displays what is in the address book, not what is in the mail. Maybe it is a similar issue here? To examine this further I reccommend looking into the email headers of the received mail to see what sender address is listed on the first hop and if that is changed later on.
Thank you so much for your advice, I tried with another external SMTP (Sendgrid) but it's blocking the emails with this error message 'This email was not sent because the From field did not contain a valid email address.'.

At least using Sendinblue as External SMTP delivers it the emails but with invalid@invalid on the from email address.
 
Are you sure there is no MAILFROM in your file(s), e.g.
# grep MAILFROM /var/spool/cron/*
yields no output?
Because that would be the only place where an individual "from" address could be placed. Else the system's sender address is used.

Are you sure that we are talking about the mail generated by cron? Or could it be that cron executes a script that sends a mail and we would actually be talking about the mail generated by the script instead? In that case you may want to check the script what it really creates as a mail header.
 
Are you sure there is no MAILFROM in your file(s), e.g.
# grep MAILFROM /var/spool/cron/*
yields no output?
Because that would be the only place where an individual "from" address could be placed. Else the system's sender address is used.

Are you sure that we are talking about the mail generated by cron? Or could it be that cron executes a script that sends a mail and we would actually be talking about the mail generated by the script instead? In that case you may want to check the script what it really creates as a mail header.
Hi Peter,

Thank again for your help, we are talking about the mail generated by the cron task execution.

The output of
# grep MAILFROM /var/spool/cron/*
grep: /var/spool/cron/atjobs: Is a directory
grep: /var/spool/cron/atspool: Is a directory
grep: /var/spool/cron/crontabs: Is a directory

Inside the crontabs directory there are files, the files seems to have defined the Cron tasks per domain, I reviewed a lot of them and none of them has MAILFROM, most of them have MAILTO="" or MAILTO="[email protected]"
 
To examine this further I reccommend looking into the email headers of the received mail to see what sender address is listed on the first hop and if that is changed later on.
 
Back
Top