Send emails from Azure with SendGrid [Exclusive Guide]

9:41 pm October 25, 20167102


If you have a mail server and you do not use Outlook or GMail account to proceed to send automatic emails, you can use the excellent service SendGrid .

This will allow you to send emails from Azure thanks to a simple CmdLet PowerShell. To do this, you simply must have an account with SendGrid… and besides the basic offer is free ! 🙂

step 1 – activate the option on your subscription Azure

it’s very simple! Connect you to your portal Azure, and create a new object SendGrid Email Delivery . You simply need to fill out some basic information: name, contact email, password, etc.


make sure the free option . Membership in such or such Resource Group is irrelevant in this case. Create him its own Resource Group If you want (or not).


Once your object is created, you simply access it again from the Azure portal and in the Configuration section, you will find the 3 following information:

  • Username (it’s from ID to authenticate when sending an email);
  • Password (your password, the one you have chosen their creation of the SendGrid object);
  • SMTP server : (that we use to deliver our emails).


Step 2 – CmdLet PowerShell to send our email

we now have to send to our email. And it’s also very simple. I use the PowerShell but the SendGrid API is very complete and there are many examples to .

 $username = "[email protected]" $pwd = ConvertTo-SecureString "your_secret_password" - AsPlainText - Force $credential = New-Object System.Management.Automation.PSCredential $username, $pwd $SMTPServer = "" $EmailFrom = "[email protected]" $EmailTo = "" $Subject = "Your subject" $Body = "Message sent successfully" Send-MailMessage - smtpServer $SMTPServer - Credential $credential - Usessl - Port 587 - from $EmailFrom - to $EmailTo - subject $Subject - Body $Body 

you have to specify the login provided by SendGrid (with the, the password you previously selected as well as the email address of the sender , the recipient and all of the contents of your email (subject + content).

After a few moments, you will receive your test email. Make sure that at the level of your Azure VM, you opened the port 587 in outbound.

In short, a super simple service to put in place, free and quite sufficient to generate emails warning, follow-up or monitoring as I need! 🙂