How to set up email notification with Gmail


#1

Good day All,

I stumbled onto this amazing tool today and i am really impressed with what it can do. I am stuck setting up mail notification when a backup run successfully see below:

--send-mail-any-operation=false
--send-mail-level=Success,Warning
--send-mail-to=
--send-mail-from="What email here"
--send-mail-subject=%backup-name% - Backup Report
--send-mail-body=%RESULT% Remote server url %LOCALPATH%
--send-mail-url=smtp.gmail.com:465 - can you assist with the URL
--send-mail-username=
--send-mail-password=########

My setup is just a normal gmail account that i want to use SMTP for and send emails from.

Thanks


Problem trying to debug problem sending mails ("Invalid type Microsoft.WindowsAzure.Storage.Blob.BlobEncryptionPolicy")
#2

How do you trigger this email? I want to do this but cant see anywhere in UI to setup


#3

Hi Richard,

I just copied the info to the bottom part of the settings option i think its called the command windows or somthing like that. On the forum some people had success sending mail. Hope i can get this sorted cause so far i like the tool.
I saw your post as well and so far no one responded .


#4

Hi, I also just came to the forum to find out how to do this :slight_smile: I hope someone will help!


#5

Hi Johan,

It seems we are in the same predicament. I like many of us really like what the tool does.


#6

You can send email reports by supplying some options to a backup job. You can do this in every backup job or in the Settings page. This is the preferred method, because you have to configure it once to make it work for all your backup jobs.

You have to specify at least one option: --send-mail-to. All other mail-related options have default values, which you can change by specifying them. So the first thing you can try is using only this option. You can test if this works by typing from the command line:
Duplicati.CommandLine.exe send-mail --send-mail-to=yourname@yourdomain.com.

If you don’t receive a test message, you can troubleshoot what’s going wrong with this command: Duplicati.CommandLine.exe send-mail --send-mail-to=yourname@yourdomain.com --verbose --log-level=profiling.

For sending mails from and/or to GMail adresses, I had to supply some other options:
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

Result was that I received a warning in my GMail mailbox, indicating that an unsafe app was trying to use my GMail account. In that warning message was a link to the settings page where the blocking could be disabled.
After allowing unsafe apps to use my GMail account, the test message was delivered successfully.

In the advanced options on the Settings page, I have specified these values for my GMail account:

--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=%PARSEDRESULT%: Duplicati %OPERATIONNAME% report for %backup-name%

Of course you can also use the SMTP server of your ISP as Smart host to deliver outgoing mail.
You can also add the options --send-mail-level=all to send an email after every backup task (including seccessful results) and --send-mail-any-operation=true to send mail after any type of operation (for example restore operations).

You can see how it works in this tutorial:

Hope this helps.


Linux : Run as service
Email files backed up / status / errors?
#7

I had issues with email notifications until I realized it was Google 2FA that was the issue. I created an app specific password for Duplicati and they work fine now.


#8

I edited your post so that the link to the tutorial is turned into an embedded YouTube video. To achieve this, you just have to post the url in a line by itself, nothing before and nothing after.


#9

Any hints on how to do this for linux? I see the command line commands, but they are for windows. Is there a unix variant of the commands?

Alternatively, is there a way to submit a command line from the webui?

thanks
david


#10

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!


#11

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.


#12

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


#13

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

#14

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


#15

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


#16

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


#17

You are missing an equal sign:

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

#18

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


#19

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?


#20

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