Script for email notification when file is uploaded through Filezilla FTP Server

<p class=“_1qeIAgB0cPwnLhDF9XSiJM”>Hi, I am looking for a script to run through Powershell so I can receive an email notification when I receive an upload from Filezilla FTP server. I have Googled and this script below I found seemed to be the best one. I entered my gmail address and password in the SMTPCClient.Credentials where gmail_address and gmail_password are but it is still not working.</p>
<p class=“_1qeIAgB0cPwnLhDF9XSiJM”>I created a bat and ps1 file. Right-clicked in the whitespace in the bottom panel of filezilla > “Action after queue completion” > Run command for bat file and set execution policy unrestricted for Powershell. Am I missing something, or does someone have a better script? Thank you.</p>

$EmailFrom= "SENDER_EMAIL"

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

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

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

Hello anuygen43,

Do you receive any error?

Does your gmail account use MFA?
If yes please refer to following article to create app password:

Also Gmail might not allow to send you email from your script as it might be considered unsecure app.
Please refer to following article:

Hope that helps.


Hi AndySvints,


Thank you for the response and your assistance. The gmail account does not use MFA and I have already allowed gmail access for this app.

I ran the script in powershell and received this error:

Exception calling “Send” with “4” argument(s): “The specified string is not in the form required for an e-mail
At C:\fn\fn.ps1:12 char:1

  • $SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
  • CategoryInfo : NotSpecified: (:slight_smile: , MethodInvocationException
  • FullyQualifiedErrorId : FormatException


What do I need to change in this line to make it work? Thanks.


Hello anuygen43,

From the error message it appears that one of the parameters ($from or $to) is not an email address.

Are you sending email to multiple recipients?

Please verify $from and $to email address.

Retype them manually if you copied them.

Hope that helps.