Send mail
How mails are being sent and what options you have.
Sending
If you use the php mail function in your code and you do not add a "From" header to this message yourself, @ will be automatically entered here. The mail also ends up in the mail log ~/domains/<domain>/var/log/mail.log
.
That is of course not very convenient and that is why we have already made this info@<domain>
for web requests. Unfortunately this is not the case with CLI scripts, cron jobs and job queues and you are therefore responsible for adjusting the "From" header yourself. You can solve this in PHP but also by passing these arguments
-d "mail.log=$HOME/domains/<domain>/var/log/mail.log"
and -d "sendmail_path=/usr/sbin/sendmail -t -i -f info@<domain>"
.
Sometimes the "From" header is not important at all and you can of course just leave it empty, in that case you have to be extra careful that the mail does not end up in the spam.
Bounces
If you try to send a mail to a non-existing mail address, the mail will be bounced. A bounced mail will be sent back to the sender.
If you did not indicate a “From” header, the email will be sent to <user>@<hostname>
and delivered locally.
Local mail
Local mail will be placed in text in /var/mail/<user>
. Of course, you are not going to look at it every day, so it is not that useful. Fortunately, we have a solution for the ~/.forward
file. Here you can store a mail address where all local mail has to be sent to.
The content of the file does not have to be more than this:
info@mydomain.com
This is useful for your CLI scripts, and also for mails that are being sent with cronjob errors with the MAILTO
variable.
Cron jobs
Normally all output from the crontab is mailed to the MAILTO address configured in the crontab. Because this often causes a lot of spam, this is disabled by default on our platform.
We recommend that you send the output of the cron jobs to a file so that you always easily can review it later.