• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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 root@something.com?


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" to@domain.com -- -r "from@domain.com" -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" to@domain.com -- -r "from@domain.com" -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.
 
hello @foxtrot.

you can change sender notifications for Plesk by adding lines below to your panel.ini:
INI:
[notification]
senderAddress=anyMbox@example.com
This doesn't work. It doesn't change the *Scheduled Tasks* from email address out of root (cron daemon). It only changes the *Notifications* from email address.
 
Is this what you're looking for?
 
Is this what you're looking for?
I tried but didn't work for me. After I executed #crontab -e, added the line MAILFROM=sender@domain.com and now I do not receive any emails from Scheduled Tasks. I removed the MAILFROM=sender@domain.com 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="name@recipient.tld"
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="name@recipient.tld"
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="name@recipient.tld"
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 my@email.com 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 site.com@cp.plesk.io

Mar 22 12:00:03 cp msmtp: host=smtp-relay.sendinblue.com tls=on auth=on user=my@email.com from=site.com@cp.plesk.io recipients=email@domain.com mailsize=72465 smtpstatus=250 smtpmsg='250 Message queued as <202303221700.92015855438@smtp-relay.sendinblue.com>' 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="corp@emailaddress.com"
 
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