After cronjob send mail with MAILTO= in top of the cronjob?

hallo,
i try to create an cronjob and at the end of the Job i want a email that the Job was done and with error or not.

i tried this
crontab -u www-data -e
MAILTO=“webmaster@beispieladresse_de”
*/15 * * * * php -f /var/www/nextcloud/cron.php
*/20 * * * * php /var/www/nextcloud/occ preview:pre-generate

is that right ?

Some cron daemons support the MAILTO="" in the crontab file. For example vixie-cron and cronie.

http://man7.org/linux/man-pages/man5/crontab.5.html

In any case. The crontab seems correct. You can check with https://crontab-generator.org

My crontab is like this:

MAILTO=""
5,20,35,50 * * * * nice -n10 php -f /var/www/domains/example.com/htdocs/nextcloud/cron.php >/dev/null 2>&1
10,25,40,55 * * * * nice -n10 php -f /var/www/domains/example.com/htdocs/nextcloud/occ preview:pre-generate -vvv >/dev/null 2>&1

hallo,
with
MAILTO=“webmaster@beispieladresse_de”
*/15 * * * * php -f /var/www/nextcloud/cron.php
*/20 * * * * php /var/www/nextcloud/occ preview:pre-generate

i dont get an email message with the result.

i try to make backups 1 / week with cron from nextcloud 1 to nextcloud 2 with rsync and want a email with the result.

how can i do this ?

My guess is that your sendmail is not properly set up.

sendmail mode doesnt work. only smtp mode work and i get the test mail. with sendail i see the green mail send button but i dont receive the email

it all depends on your cron; check whether you use a per-user or a system-wide crontab.
if your cronjobs work satisfactorily except for the mail-sending i suggest another approach: let your backup-scripts send the email independently of cron. this also has the advantage that you do not get an email every 15 and every 20 minutes.

i ususally run backup-scripts as root, parse or tail their logfile(s) and then send the relevant stuff by mail.
GOOD LUCK!

hmm, i followed the howto and create the cron with
crontab -u www-data -e
this is a systemcron or not ?

the cronjob doesnt work…
when i start the script the backup start (without emal message) but not with cron……

To run cronjobs you can use easycron.com which allows great control, it sends out alerts email if a cron job fails or succeeds.