Last updated: 24 Mar 26 02:24:23 (UTC)

Using own SMTP server with FreeFileSync

Here’s a ready-to-use PowerShell solution you can plug directly into FreeFileSync to send email via your own SMTP server 👍


✅ Option 1 (Recommended): Modern PowerShell SMTP (works with most servers)

This uses .NET instead of the deprecated Send-MailMessage

📄 Save this as: send-mail.ps1

param( [string]smtpServer="smtp.yourserver.com",[int]smtpServer = "smtp.yourserver.com", [int]port = 587, [string]username="your@email.com",[string]username = "your@email.com", [string]password = “yourpassword”, [string]to="recipient@email.com",[string]to = "recipient@email.com", [string]from = “your@email.com”, [string]subject="FreeFileSyncJobCompleted",[string]subject = "FreeFileSync Job Completed", [string]body = “Your sync job has finished successfully.” )

Create SMTP client

smtp=NewObjectSystem.Net.Mail.SmtpClient(smtp = New-Object System.Net.Mail.SmtpClient(smtpServer, port)port) smtp.EnableSsl = $true

Credentials

smtp.Credentials=NewObjectSystem.Net.NetworkCredential(smtp.Credentials = New-Object System.Net.NetworkCredential(username, $password)

Create message

message=NewObjectSystem.Net.Mail.MailMessagemessage = New-Object System.Net.Mail.MailMessage message.From = fromfrom message.To.Add(to)to) message.Subject = subjectsubject message.Body = $body

Send email

smtp.Send(smtp.Send(message)


⚙️ How to hook this into FreeFileSync

  1. Open your sync job in FreeFileSync

  2. Go to:

Menu → Options → Run command after sync

  1. Enter something like:

powershell.exe -ExecutionPolicy Bypass -File “C:\Scripts\send-mail.ps1”


🧠 Make it more useful (include result info)

FreeFileSync can pass variables to your script.

Use this instead:

powershell.exe -ExecutionPolicy Bypass -File “C:\Scripts\send-mail.ps1” -subject "Sync Result: %result%" -body “Job finished with result: %result% at %time%”

Useful variables:

%result% → Success / Warning / Error

%error_count%

%warning_count%

%time%


🔐 Important (don’t skip this)

Hardcoding passwords is not ideal. Better options:

Option A (quick & easy)

Use an app password (Gmail, Outlook, etc.)

Option B (more secure)

Store credentials encrypted:

Run once to create secure password file

“yourpassword” | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File C:\Scripts\smtp.txt

Then modify script:

KaTeX parse error: Undefined control sequence: \Scripts at position 28: … Get-Content C:\̲S̲c̲r̲i̲p̲t̲s̲\smtp.txt | Con…cred = New-Object System.Management.Automation.PSCredential($username, securePass)securePass) smtp.Credentials = $cred


⚠️ Gmail / Outlook specifics

Gmail

SMTP: smtp.gmail.com

Port: 587

Requires App Password (NOT your normal password)

Outlook / Office365

SMTP: smtp.office365.com

Port: 587

TLS required