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]port = 587, [string]username = "your@email.com", [string]password = “yourpassword”, [string]to = "recipient@email.com", [string]from = “your@email.com”, [string]subject = "FreeFileSync Job Completed", [string]body = “Your sync job has finished successfully.” )
Create SMTP client
smtp = New-Object System.Net.Mail.SmtpClient(smtpServer, port) smtp.EnableSsl = $true
Credentials
smtp.Credentials = New-Object System.Net.NetworkCredential(username, $password)
Create message
message = New-Object System.Net.Mail.MailMessage message.From = from message.To.Add(to) message.Subject = subject message.Body = $body
Send email
smtp.Send(message)
⚙️ How to hook this into FreeFileSync
-
Open your sync job in FreeFileSync
-
Go to:
Menu → Options → Run command after sync
- 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:
securePass = Get-Content C:\Scripts\smtp.txt | ConvertTo-SecureString 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) 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