jetmore / swaks

Swaks - Swiss Army Knife for SMTP
http://jetmore.org/john/code/swaks/
GNU General Public License v2.0
847 stars 86 forks source link

Gmail compatible settings (2022) #54

Closed bigteejay closed 1 year ago

bigteejay commented 1 year ago

I spent quite a bit of time trying to nail down the specific settings for sending programmatic emails through Gmail (using swaks to verify).

I figured I would document it here in case it helps anyone else.

Following this link (and enabling 2FA/two-factor-authentication), then create an app password to use for signing into the mail server.

Docker route (not required, other swaks Docker images exist, but this was the most useful)... swaks.Dockerfile ``` FROM ubuntu:20.04 RUN apt update && echo y | apt install swaks vim ``` Build... `docker build -t swaks $PWD\swaks.Dockerfile` Run... `docker run -it --rm swaks sh`

Finally, try test email...

swaks -4 --server smtp.gmail.com -tlsc --tls-protocol TLSv1_2 \
    --from [your full gmail account email that app password was setup for] --to user1@example.com,user2@example.com \
    --auth LOGIN --auth-user [same as from] --auth-password [your generated app password] -apt \
    --h-Subject 'Test email' --body 'Email system test.'

The -apt argument isn't required of course, it just helped with troubleshooting. Not using "smtp-relay..." for the server as what little Google documentation exists indicated, was necessary. Do not consider this a "secured" example, merely for testing purposes.

I'll try closing this "issue" if allowed so as to not create more work for admins.