If you tried to send mails from your NAS having your gmail account as sender address, you might ended up in searching your mails in the SPAM folder. This is because the mail is not sent using the google SMTP server. However you can fix that by following the next steps:
- In DSM, install the package “E-Mail Server”
- Run the “E-Mail Server” app to start the configuration
- Click on “SMTP” and tick the “Enable SMTP” checkbox
- Tick the “Authorization required for mail clients except Mail Station” if you only want to send mails from the NAS itself.
- Click on SMTP relay
- Tick “Enable SMTP Relay”
- Server is: smtp.gmail.com
- Port is: 587
- Choose “Always use a secure connection (TLS)”
- Tick “Authentication Required” and enter your gmail account and password. Don’t forget to add the “@gmail.com” behind your gmail account.
- Click OK twice (first on relay setup, then on e-mail server setup)
Now your done. Login to your NAS using your favorite SSH client and try to send a mail:
DiskStation> sendmail -F “Synology Station” -f “email@example.com” -t firstname.lastname@example.org << EOF
Subject: Synology Mail Test
Seems to work. Hooray.
Check your gmail inbox and there you are. You can now use this command in your scripts.