Using sendmail from the command line

I am trying to write a bash script that will be executed by a cron job which, under certain circumstances, will send me an email.

To try to get sendmail to work with the Sendgrid SMTP settings, I 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 the postfix using sudo / etc / init.d / postfix restart

And tried to send an email from the command line using the following command:

sendmail my@email.com </tmp/email.txt

The result is the following:

You have new mail in / var / mail / ubuntu

Why send sendgrid with my email inbox using the Sendgrid SMTP parameters specified in main.cf?

Please note that this question only applies to sendmail, I do not want to install other SMTP clients and applications, it should work as is.

+6
source share
1 answer

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 an email message through a bash script is done as follows:

 sendmail email@address.com <<EOF subject:This is a test from: from@address.com Body message here... EOF 
+10
source

Source: https://habr.com/ru/post/944608/


All Articles