FileZilla Email Notifications on Queue Completion

Setting up email notifications when a FileZilla queue finishes is super-easy and this article will explain how to do it in a Windows environment.

Prerequisites

Steps

1. Create a folder on your C: drive called “fn”
2. Create two files in this folder called “fn.bat” and “fn.ps1”
3. Open fn.ps1 in your text editor and enter the following:

$EmailFrom = "SENDER_EMAIL"
$EmailTo = "RECIPIENT_EMAIL"
$Subject = "EMAIL_SUBJECT"
$Body = "EMAIL_BODY"

$SMTPServer = "smtp.gmail.com"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$SMTPClient.EnableSsl = $true

$SMTPClient.Credentials = New-Object System.Net.NetworkCredential("GMAIL_ADDRESS", "GMAIL_PASSWORD");

$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)

4. Open fn.bat and enter the following:

powershell "C:\fn\fn.ps1"

5. Open FileZilla and start an upload/download
6. Right-click in the whitespace in the bottom panel > “Action after queue completion” > Run command…
7. Enter the following line in the popup:

C:\fn\fn.bat

8. Now when the queue is complete the email specified in Step 3 will be sent.

What’s Happening?

First we wrote a PowerShell script which sends an email through Google’s SMTP servers, but FileZilla can’t run it directly so you must make a batch file which can. Then, you simply tell FileZilla to run the batch script when all transfers are complete.

Problems?

Powershell has what’s called an Execution Policy (read the Execution Policy TechNet documentation for more info) so for this to work you must set it to Unrestricted before any of the above will work by running the following command in an Administrative PowerShell prompt (Right-click on PowerShell > Run as Administrator):

Set-ExecutionPolicy Unrestricted

Also, on a 64-bit machine, “Powershell” and “Powershell(x86)” are two separate applications with independent Execution Policies! In my tests the 32-bit version was called by the batch script, but you may as well set the execution policy for both.

Conclusion

Whilst it may seem a bit elaborate to call a batch file which calls a PowerShell script to send an email, as far as I’m aware this is the easiest way to receive email notifications from FileZilla.

You could also use a command line program to send the email – MailSend for example, although I haven’t tested this myself and I much prefer Powershell to third-party applications. If you know any alternative (or easier!) methods let me know.

Leave a Reply

Your email address will not be published. Required fields are marked *