Using Powershell from my local desktop, I am able to successfully send an outgoing email to our O365 email server:

$mycredentials = Get-Credential 
Send-MailMessage -smtpServer company.mail.protection.outlook.com -credential $mycredentials -from 'name@company.com' -to 'name@company.com' -subject 'TestSubject'

However, I get an error using the exact same commands/credentials/values when attempting to send mail from the Azure VM.

I have opened Port 25 and 587 on both the Windows Firewall and the Azure Firewall for the VM.

Any other suggestions on why this might be working on my local desktop but not on the Azure VM?


Port 25 is blocked by Azure (even after allowing on Windows and Azure firewalls), but you can add SendGrid as a resource in Azure then use Port 2525 instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.