SchumacherFM / mailout

mailout - a https://caddyserver.com/ V1 SMTP client email middleware with PGP encryption
https://caddyserver.com/docs
Apache License 2.0
78 stars 13 forks source link

Unable to start Caddy on bootup with Mailout #17

Open rojakcoder opened 5 years ago

rojakcoder commented 5 years ago

I "installed" Caddy as a service on systemd (Ubuntu 18.04).

I'm able to start the service manually like so: sudo systemctl start caddy.service

I then tried making the service start upon system boot up: sudo systemctl enable caddy.service

It does not work.

I'm using a Gmail account to send out emails. However, Google is blocking access when the service is being started during boot up - says "Unusual sign-in attempt prevented".

It works fine if I start the service manually.

I can see from the logs below (sudo journalctl --boot -u caddy.service) that Google is requiring me to re-authenticate if starting the service upon bootup. Of course I am unable to do so if the service is being start during bootup.

Jan 16 23:19:36 localhost caddy[687]: 2019/01/16 23:19:36 534 5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsdt4
Jan 16 23:19:36 localhost caddy[687]: 5.7.14 KMifBMHp57kD9RRt1qDo8iaOrx9MFzJ0SLXVy854ySa6MjdptNhnAj_e6c4TXEVWV0iuk1
Jan 16 23:19:36 localhost caddy[687]: 5.7.14 53P-GCWyuGJ1ybfcoqIu4khdjVH92N_7EBlec7u3peHNL6ODOeEaWIbOupMd_c3lEWEfAI
Jan 16 23:19:36 localhost caddy[687]: 5.7.14 rzk7HwR-F0d7g8wv0ijgCY-x3uevjbMAFbPcysmoDBG5sy48guJefty5g_fulA3oUkVryS
Jan 16 23:19:36 localhost caddy[687]: 5.7.14 TSb-0mMSD-SBNJjhC0B09YTo5HwZltEJrwQZS6NTncHVNsdmkF> Please log in via
Jan 16 23:19:36 localhost caddy[687]: 5.7.14 your web browser and then try again.
Jan 16 23:19:36 localhost caddy[687]: 5.7.14  Learn more at
Jan 16 23:19:36 localhost caddy[687]: 5.7.14  https://support.google.com/mail/answer/78754 c7sm14904972pfh.18 - gsmtp
Jan 16 23:19:36 localhost systemd[1]: caddy.service: Main process exited, code=exited, status=1/FAILURE
Jan 16 23:19:36 localhost systemd[1]: caddy.service: Failed with result 'exit-code'.

I was wondering if anyone has any experience in getting Mailout to work with Gmail for auto-start Caddy service on systemd.

SchumacherFM commented 5 years ago

It does work but you must configure your google account that less secure apps can access your google account. If i remember correctly you can use app specific passwords when you have 2FA enabled.

rojakcoder commented 5 years ago

The setting is turned on (screen cap 1).

As mentioned, Google seems to require re-authentication when Caddy boots up. I believe when I couldn't do so, Google flags it as a suspicious sign-in attempt (screen cap 2).