I'm trying to write a bash script, to be run by a cron task, which will send me an email under certain circumstances.
In order to try and get sendmail working with my Sendgrid SMTP settings, I've edited the /etc/postfix/main.cf file with the following:
smtp_sasl_password_maps = static:<username>:<password>
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
smtp_tls_security_level=encrypt
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587
I restarted postfix using sudo /etc/init.d/postfix restart
And tried sending an email from the command line using the following command:
sendmail [email protected] < /tmp/email.txt
This results in the following output:
You have new mail in /var/mail/ubuntu
Why isn't sendgrid sending with my email using the Sendgrid SMTP details I specified in main.cf?
Please note, this question relates to sendmail only, I don't want to install other SMTP clients and apps, it needs to work as is.
My Postfix configuration was wrong. I needed to use the following:
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = static:<username>:<password>
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = may
header_size_limit = 4096000
relayhost = [smtp.sendgrid.net]:587
Sending the email via bash script is done as follows:
sendmail [email protected] <<EOF
subject:This is a test
from:[email protected]
Body message here...
EOF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With