Create emails for my domain linked to Azure web service

IT_DrKaako 21 Reputation points
2022-01-16T19:30:36.013+00:00

Hello,

I have MSFT Partner Plan. I have created App Service and linked it to my domain (www.drkaako.com). Now, I want to create emails for that domain (like ******@drkaako.com).
Could you please help me with the steps?

P.S.
* I purchased the domain from google domains
* The current Partner Plan is linked to my other org (https://www.avicennacares.com/).

Thanks!

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. David Warwick 121 Reputation points
    2022-01-27T03:21:27.787+00:00

    @IT_DrKaako , I am not sure how to do that without purchasing a service. I suppose you could set-up your own mail server. But I took the easy route and purchased an email account from GoDaddy for my domain. I purchased the domain from GoDaddy as well.

    The email address I purchased was ******@mydomain.com. I can send emails from that account by logging into the account from Microsoft Outlook, or I can also send emails from my ASP.Net MVC app using Twillo Sendgrid. See below for an example.

    using SendGrid;  
    using SendGrid.Helpers.Mail;  
    using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Threading.Tasks;  
      
    namespace MyShoppingCart.Helpers  
    {  
        public static class SendGridStatic  
        {  
            public static async Task Execute(string sSendGridKey, string sFromEmail, string sFromName, string sSubject, string sToEmail, string sToName, string sPlainTextContent = "", string sHTMLContent = "")  
            {  
                var apiKey = sSendGridKey;  
                var client = new SendGridClient(apiKey);  
                var from = new EmailAddress(sFromEmail, sFromName);  
                var subject = sSubject;  
                var to = new EmailAddress(sToEmail, sToName);  
                var plainTextContent = sPlainTextContent;  
                var htmlContent = sHTMLContent;  
                var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);  
                var response = await client.SendEmailAsync(msg);  
            }  
        }  
    }  
    

    An example of calling that method:

    private async Task SendConfirmationEmail(ApplicationUser user)  
            {  
                string sEmailToken = await _userManager.GenerateEmailConfirmationTokenAsync(user);  
                string sURL = $"{_configuration.GetValue<string>("SiteURL")}Account/Verify?Id={Uri.EscapeDataString(user.Id)}&token={Uri.EscapeDataString(sEmailToken)}";  
                string sPlainTextContent = $"Please click the following link to verify your email: {sURL}";  
                string sHTMLContent = $"<strong>Please click the following link to verify your email:</strong><br>{sURL}";  
      
                await SendGridStatic.Execute(_configuration.GetValue<string>("SendGridKey"), "******@mydomain.com", "Customer Service", "Please Verify Your Account", user.Email, user.FullName, sPlainTextContent, sHTMLContent);  
            }  
    

    I had to get a FREE Sendgrid account, and do some set-up in order to have access to the SendGrid API in order to get this to work, but it wasn't too difficult.

    Does that answer your question?

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. David Warwick 121 Reputation points
    2022-01-17T02:49:37.413+00:00

    I purchased my domain through GoDaddy. GoDaddy offered to provide me with an email account for my domain. I use Twillo Sendgrid to actually send the emails for me. You can search for Sendgrid in the Azure portal and actually sign up for an account.

    0 comments No comments

  2. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2022-01-26T09:17:06.093+00:00

    @IT_DrKaako , Just checking in to see if the previous response helped answer your question. Kindly let us know if you have any further questions on this specific topic, we would be more than happy to assist you.

    Just adding to DavidWarwick-6573’s response. Based on your requirement, you could also leverage Azure Logic Apps.

    It is recommended that you use authenticated SMTP relay services to send email from Azure VMs or from Azure App Service (in your case). (These relay services typically connect through TCP port 587, but they support other ports. As David mentioned, SengGrid is one such service.

    --Using these email delivery services isn't restricted in Azure, regardless of the subscription type.

    You could send emails with Gmail from your App Service app by using Azure Logic Apps. Logic Apps brings a lot more power to your App Service app without adding complexity to your code.
    Tutorial: Send email and invoke other business processes from App Service

    Refer this doc -Recommended method of sending email

    Additionally -
    This guide demonstrates how to perform common programming tasks with the SendGrid email service on Azure. The samples are written in PHP. The scenarios covered include constructing email, sending email, and adding attachments.
    How to Use the SendGrid Email Service from PHP

    Also, This is a Proof of Concept to send email using the PHP Mailer library and Office 365.
    Send email on App Service using Office 365 (O365)

    -------
    To benefit the community find the right answers, please do mark the post which was helpful by clicking on ‘Accept Answer’ & ‘Up-Vote’.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.