M365 SMTP Relay (Exchange Online) and configuration in abp
Has anyone tried to establish sending emails via Exchange Online (Microsoft 365 - Business plans, not Personal) via abp application (which is hosted on server with unique IP address)?
I know, that SMTP Relay for specific IP address should be configured as described here: https://lazyadmin.nl/office-365/smtp-relay-in-office-365/
But I haven't figured out how to properly configure abp emailing settings: https://docs.abp.io/en/abp/latest/Emailing#email-settings
Thank you for your suggestions.
I found a solution how to send email via M365 SMT Relay from scratch in C#, but I still haven't found how to properly set abp emailing configuration.
Here is a sample c# application:
using System;
using System.Net.Mail;
class Program
{
static void Main()
{
string senderEmail = "[email protected]";
string senderDisplayName = "Sender Name";
MailAddress mailAddressSender = new MailAddress(senderEmail, senderDisplayName);
string recipientEmail = "[email protected]";
MailAddress recipientAddress = new MailAddress(recipientEmail);
MailMessage message = new MailMessage(mailAddressSender, recipientAddress);
message.From = mailAddressSender;
message.Subject = "Hello from .NET Console App";
message.Body = "This is the email body.";
string host = "<name>.mail.protection.outlook.com";
int port = 25;
SmtpClient smtpClient = new SmtpClient(host, port);
smtpClient.EnableSsl = true;
try
{
Console.WriteLine("Try Email send.");
smtpClient.Send(message);
Console.WriteLine("Email sent successfully.");
}
catch (Exception ex)
{
Console.WriteLine("Failed to send email. Error message: " + ex.Message);
}
}
}
@maliming do you maybe have suggestions for this question? Thank you
hi
Add your EmailSender and override the BuildMailMessage and BuildClientAsync method
If you need additional parameters, please use: https://github.com/abpframework/abp/pull/17582