0

I'm trying to send an email through cron and ssmtp. I created a script with this

#!/bin/bash
printf "Subject:test\n\Test text" | ssmtp email@adress.com

The script works fine when run from the prompt but doesn't work through cron. Ssmtp is sending through gmail if that matters.

The weird thing is according to mail.log the email sent fine.

axlrose
  • 3
  • 2
  • If the script works (in the sense of no errors and mail log showing that message was submitted OK) but message doesn't appear in the Gmail mailbox then the most likely cause is that the message is being flagged as spam. Have you checked the spam folder on Gmail? – Paul Haldane Jun 16 '15 at 07:39

1 Answers1

0

Here are detailed instructions including gmail.

http://www.pickledbrain.com/2011/04/setting-simple-outgoing-email-on-a-ubuntu-server-using-ssmtp/

The command is

 #!/bin/bash
 printf "Subject:test\n\Test text" | mail email@adress.com
Arlion
  • 608
  • 1
  • 5
  • 17
  • That worked...Thanks!!! Just curious as to why it works with mail and not ssmtp? I was under the impression that ssmtp was stand alone, so why does cron need mailx installed? – axlrose Jun 16 '15 at 01:36
  • Perform the command ssmtp in a terminal. Is ssmtp installed? – Arlion Jun 16 '15 at 01:38
  • Yes it is. The script that I posted above works fine if it isn't run from cron. – axlrose Jun 16 '15 at 01:49