-1

SO: Ubuntu 18.04.6 Postfix: 3.3.0 GNUmailutils 3.4

I've a script that send email to office/outlook user. If I start script from terminal, email arrive correctly to user. If i set same script on crontab, email arrive to user but is signed by MS with "Some people who have received this message do not often receive e-mails from " How can I solve?

6
  • Hello. A good start to solving any problem is to have correct info. There is no such version of Ubuntu as 18
    – David DE
    Commented Apr 13, 2022 at 14:50
  • Could you describe more specifically what is the actual problem?
    – raj
    Commented Apr 13, 2022 at 14:56
  • If start script from terminal mail arrive correctly. If I use crontab to start script mail arrive but MS outlook signed with message ""Some people who have received this message do not often receive e-mails from " I search online and I read that is an antiphishing protection.
    – paoloD77
    Commented Apr 13, 2022 at 15:12
  • 1
    I suspect it's something to do with differences in the mail header that trigger the recipient's mail filters (for example, the originator appearing to be root@localhost or somesuch). But to have any hope of answering this, you'll need to provide much more detail - how does your script send email? what MTA are you using, and how is it configured (particularly any reverse aliases)? Whose crontab are you running the script from? Commented Apr 13, 2022 at 17:31
  • What is the sender of the e-mail that you send directly from terminal and what is the sender of the e-mail sent from crontab? View full exact headers of both emails and try to find differences. These differences are the reason for the Outlook message you quote.
    – raj
    Commented Apr 13, 2022 at 18:58

1 Answer 1

0

Jobs run through cron aren't run in the same runtime environment that you have on your desktop. None of your PATH changes, or other environment variable settings from ~/.bashrc are automatically propagated to your cron job. For example, there's no $DISPLAY, so GUI programs need special treatment (read man xhost).

One can set environment variables for all one's cron jobs in the crontab file Read man 5 crontab.

Look at the results of echo "=== id ===";id;echo "=== set ===";set;echo "=== env ===";env | sort;echo "=== alias ===";alias in each of your environments.

Since the command part of the crontab line is, by default, interpreted by /bin/sh, which has a simpler syntax than /bin/bash, I recommend having command be a call to a bash script (executable, mounted, starts with #!/bin/bash) which sets up the environment, then calls the desired program.

1
  • Script is executable, start with #!/bin/bash Example: #!/bin/bash echo -e "From:USER@THIS_SERVER\nTo: EXTERNAL_USER@OUTLOOK\nSubject: TEST\n\n BODYTEST " | sendmail -t
    – paoloD77
    Commented Apr 14, 2022 at 10:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .