How to set up email notification with Gmail

Can you try: --send-mail-url=smtps://smtp.office365.com:587

That is supposed to do TLS and works for me for gmail. Maybe forming it a bit differently will work?

david

I edited your post to improve the formating. (Just added ~~~ before and after the output you pasted, see here for details).

There are some formatting issues. The options must be prefixed with two hyphens: --

You are missing an equal sign:

--send-mail-url=smtp://smtp.office365.com:587

I had checked the settings dropdown but on my screen the scrollbar is not visible suggesting only a few options. I had to scroll the list using the keyboard

Still not working. Ok to start from the beginning i wanted to test the mail function from the commandline:

I run - Duplicati.CommandLine.exe send-mail --send-mail-to=**********@***.*** --verbose --log-level=profiling and i get this error:
Input options:
send-mail-to: ***********@*******.org
verbose:
log-level: profiling

Starting - Running SendMail
Running SendMail took 00:00:00.031
Failed to send email with server: smtp://ASPMX.L.GOOGLE.COM, message: An attempt was made to access a socket in a way forbidden by its access permissions 74.125.71.27:25, retrying with smtp://ALT2.ASPMX.L.GOOGLE.COM => An attempt was made to access a socket in a way forbidden by its access permissions 74.125.71.27:25
Failed to send email with server: smtp://ALT2.ASPMX.L.GOOGLE.COM, message: An attempt was made to access a socket in a way forbidden by its access permissions 74.125.24.26:25, retrying with smtp://ALT1.ASPMX.L.GOOGLE.COM => An attempt was made to access a socket in a way forbidden by its access permissions 74.125.24.26:25
Failed to send email with server: smtp://ALT1.ASPMX.L.GOOGLE.COM, message: An attempt was made to access a socket in a way forbidden by its access permissions 173.194.73.26:25, retrying with smtp://ALT3.ASPMX.L.GOOGLE.COM => An attempt was made to access a socket in a way forbidden by its access permissions 173.194.73.26:25
Failed to send email with server: smtp://ALT3.ASPMX.L.GOOGLE.COM, message: An attempt was made to access a socket in a way forbidden by its access permissions 64.233.187.26:25, retrying with smtp://ALT4.ASPMX.L.GOOGLE.COM => An attempt was made to access a socket in a way forbidden by its access permissions 64.233.187.26:25
Failed to send email: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 74.125.28.27:25
 => An attempt was made to access a socket in a way forbidden by its access permissions 74.125.28.27:25 

Sorry for my ignorance and too many questions but is the a SOP with a step by step guide what to do and can all this be done from a normal gmail account without configuration from the gmail account?

When you are using Google (and most other email providers) you need to specify the SMTP server. Duplicati tries to use the publicly announced SMTP servers if you do not specify one. But Google does not allow you to send email with their public servers, as they are used to receive email only.

The error messages you see are because something on your OS prevents connecting to port 25 (SMTP). This is quite common and guards against some mass spamming virus/worms.

This indicates that your firewall/antivirus also shuts off access to the SSL version of the socket. You need to whitelist Duplicati to get the emails sent.

The full setup should look like this (in one line):

Duplicati.CommandLine.exe send-mail 
--verbose 
--log-level=profiling
--send-mail-to=youraddress@gmail.com 
--send-mail-from=youraddress@gmail.com 
--send-mail-url=smtps://smtp.gmail.com:465 
--send-mail-username=youraddress@gmail.com 
--send-mail-password=yourpassword

You can also try the StartTLS version that Google offers, by using this url instead:

--send-mail-url=smtp://smtp.gmail.com:587?starttls=always
1 Like

Hi Ken,

Some great news i tried email notification ini a VM and the emails are been send now I think my pc firewall or AV was blocking the mails to be send :ok_hand:

One thing is that i get the following error at the end of the email:

]
Warnings: [
    The supplied option --auth-u is not supported and will be ignored
]
Errors: []

I dont think i have configured --auth-u anywhere or what option is this?

Thanks,

Try to export the backup to commandline format and see if you can spot it somewhere.

1 Like

Hi Ken,

I really need to say Thanks you and to all the guys who assisted with this i think my emails and backup are running 100% now. So for me now it’s just about fine tuning my configuration e.g. to send mail only for warnings. Thanks u again much appreciated.

Thanks,:raised_hands:

1 Like

BTW: A good way of showing your appreciation for a post is to like it: just press the :heart: button under the post.

If you asked the original question, you can also mark an answer as the accepted answer which solved your problem using the tick-box button you see under each reply.

All of this also helps the forum software distinguish interesting from less interesting posts when compiling summary emails.

1 Like

Is it possible to get support for line breaks / new lines / carriage returns in the message body?

Something like this:

–send-mail-body="%OPERATIONNAME%: %PARSEDRESULT% \n\n Backup For: %backup-name% \n\n %RESULT%"

I have no idea if this would work, but I’m guessing something like this in SendMail.cs under ReplaceTemplate:

input = Regex.Replace(input, "\\n", Environment.NewLine, RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
1 Like

You can also supply a filename for --send-mail-body. If the file exists, Duplicati will do the template expansion on the file contents instead.

But maybe your solution is still nice, in that it is easier if the config is stored entirely in the job configuration.

A post was split to a new topic: Setting up email via web-interface not working

Hi Ken,

I found three occurences of a typo in the online help text shown in the GUI -> Settings -> Options for the advanced option send-mail-url regarding STARTTLS. In the composed URL, the / in front of ? should be removed.

Is: smtp://example.com:25/?starttls=<always|when-available|never>
Should be: smtp://example.com:25?starttls=<always|when-available|never>

scmarti,

I think you would be correct if the URL was to a specific page (such as default.html) but when a URL goes to a folder it relies on the web server to decide the default page to show - the “/” is needed so the web server knows a specific page is being requested.

Granted, the top level (root) folder MIGHT work without the “/”, but by including it we stay consistent with other non-top level scenarios.

Hi JonMikeIV,

thank you for explaining. For top level URLs this is definitely working. When my send-mail scenario failed I thought the (in my view: extra) slash was the culprit. I later found out that actually it was my mail server’s invalid certificate. I fixed that using the option “accept-specified-ssl-hash”. My test using the example’s syntax then were successful.

Thank you for quick help!

1 Like

After some problems with Gmail using sendEmail and other such tools, I ended up creating a Yahoo email just for notifications and it was the best thing I did, it worked perfectly and without headaches for more than 3 years.

Thanks kees-z, this configuration worked perfectly for me on Windows 10 boxes.
Also thanks to kenkendk for his linux advice - I’ll try that next.

I first created a Google app password for Duplicati to use for sending emails (otherwise Google will reject the smtps send mail). Then I copied, pasted and customized your example into Duplicati.

Best Regards

2 Likes

It works perfectly with Version: 2.0.6.1 (2.0.6.1_beta_2021-05-03) on Win10. I checked today. Thanks!