Update:
Starting on November 15, 2017, outbound email messages that are sent
directly to external domains (such as outlook.com and gmail.com) from
a virtual machine (VM) are made available only to certain subscription
types in Microsoft Azure. Outbound SMTP connections that use TCP port
25 were blocked. (Port 25 is primarily used for unauthenticated email
delivery.)
This change in behavior applies only to new subscriptions and new
deployments since November 15, 2017.
This is the doc:
https://learn.microsoft.com/en-us/azure/virtual-network/troubleshoot-outbound-smtp-connectivity
Azure recommend to use third party SMTP relay like SendGrid to send email.
Original Answer:
I am not sure the language you are using now, so I assume you are using C#.
Below is how to use SendGrid in azure function:
For example, if you want to send email from email A to email B.
First of all, install package Microsoft.Azure.WebJobs.Extensions.SendGrid
.
go to the sendgrid website, create a sender and verify the email A:

After that, email A is ready to send emails by sendgrid.
Now we need to generate a SendGrid API key and copy and store the API key:(This will be filled in the Values section of local.settings.json as an environment variable to read.)

Then, you can use it to send emails
Use SendGrid Binding:
using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SendGrid.Helpers.Mail;
namespace FunctionApp40
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
[SendGrid(ApiKey = "CustomSendGridKeyAppSettingName")] out SendGridMessage message,
ILogger log)
{
message = new SendGridMessage();
message.AddContent("text/plain","This is a test.");
message.SetFrom("emailA@emailA.com");
message.AddTo("emailB@emailB.com");
message.SetSubject("This is send from Function app.");
log.LogInformation("This is a test.");
}
}
}
local.settings.json:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"CustomSendGridKeyAppSettingName": "SG.XQ9uKeO3QCmNH7hA8qP8eA.xxxxxx"
}
}
Works fine on my side:

By the way, this can only guarantee successful delivery, because some mailboxes refuse to accept mail sent through sendgrid. In this case, you will still get a 200 response, but the recipient will not receive the mail.(In this case, the recipient needs to go to the mailbox settings to lift the relevant restrictions.)