简体   繁体   中英

Sender email using mailx and gmail SMTP cert

I wrote a pretty easy script to send some emails using mailx. The script is working fine but I'm trying to use a different sender email address and I've tried almost everything and is not working for me. I have the feeling that the gmail cert somehow is overwriting whatever I'm defining as the sender.

This is the code:

for i in ${EMAILS[@]}; do
    mailx -s "Let me introduce myself" -r "Company <company@company.com>" -S replyto="company@company.com" $i <<eof
    Hello World,

    I'm an automate email 

    eof
done

Everytime that I recevie an email the sender email is "Company mypersonalgmail@gmail.com".

I've added this lines at the end of the main.cf file on /etc/postfix

relayhost = [smtp.gmail.com]:587 
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt

And finally, I've created the /etc/postfix/sasl_passwd file with my personal gmail info (login+password).

Any kind of help would be much appreciated.

Thanks!

I've solved the issue. I've just added a new domain for my personal email account and now I can send emails with a different domain with the -r option.

This code also works:

echo "This is the message body and contains the message" | mailx -v -n -r "x@domain.com" -s "This is the subject" -S smtp="smtp.server:port" -S smtp-use-starttls -S ssl-verify=ignore  -S smtp-auth-user="user@domain.com" -S smtp-auth-password="pasword" -S ssl-verify=ignore to_email@domain.com

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM