FluentEmail icon indicating copy to clipboard operation
FluentEmail copied to clipboard

Specify LocalEndPoint/IP Address for where to send email from

Open Gaz83 opened this issue 2 years ago • 1 comments

Is there a way to specify the IP address of where to send emails from?

My host is moaning because the server I send from has multiple IP addresses and it triggers the Anti-Abuse system when sending large volumes of emails.

I am using MailKitSender and I believe this supports localendpoint configuration.

Gaz83 avatar May 03 '23 16:05 Gaz83

Made some changes in a local project to test but this is my suggested changes.

In SmtpClientOptions add an extra property .

public IPEndPoint LocalEndPoint { get; set; }

Then in the class MailKitSender, in both Send and SendAsync where you create the SmtpClient add this

if (_smtpClientOptions.LocalEndPoint != null) { client.LocalEndPoint = _smtpClientOptions.LocalEndPoint; }

Gaz83 avatar May 05 '23 09:05 Gaz83