How to set up email notification with Gmail

Hi David, I am with you, concerning using linux, I am planning to play with the info above on monday, and see if i can get it sorted out. I will try on ubuntu 16.04. will keep you posted.

thank you all for the great info!

For Linux you can do exactly the same, just replace Duplicati.CommandLine.exe with duplicati-cli. If the duplicati-cli is not in your path (for whatever reason), you can use the Windows command verbatim and just add mono in front:

mono Duplicati.CommandLine.exe send-mail --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 --send-mail-subject=Testmessage --verbose --log-level=profiling

Some Linux distros even allow you to run it without the mono command, but it never hurts to add it.

Thanks for the pointer.

When I try this I get:

Input command: send-mail
Input arguments:
        -send-mail-password=<my password which has special characters>

Input options:
send-mail-to: username@hotmail.com
send-mail-from: username@hotmail.com
send-mail-url: smtps://smtp.gmail.com:465
send-mail-username: username@gmail.com
send-mail-subject: Testmessage
verbose:
log-level: profiling

Command takes no arguments

Are there limits to the characters in you password when run on the command line?

UPDATE: If I put the password as the last option on the command line it worked.

thanks
david

Hi Kees-z,

I tried to follow your instructions but got the following error: "Am i doing something wrong?

Starting - Running SendMail
Running SendMail took 00:00:00.012
Failed to send email: System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions 64.233.167.108:465
 => An attempt was made to access a socket in a way forbidden by its access permissions 64.233.167.108:465

Or

The supplied option --send-mail-smtp://smtp.office365.com:587/?starttls is not supported and will be ignored
Starting - Running SendMail
Running SendMail took 00:00:00.012
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 66.102.1.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 66.102.1.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://ALT2.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://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://ALT3.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://ALT3.ASPMX.L.GOOGLE.COM, message: An attempt was made to access a socket in a way forbidden by its access permissions 64.233.188.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.188.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

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.