Я использую .net 5 для отправки электронной почты из бэкэнда на тот же почтовый клиент в Outlook. Я попытался отправить на другой адрес электронной почты, однако я все еще получаю то же сообщение об ошибке. Используя отладку, я обнаружил, что исключение перехватывается в коде client.Send(message);. Это когда появляется сообщение об ошибке. Почему я получаю это сообщение об ошибке и как его решить?
Сообщение об ошибке
> Exception has occurred: CLR/System.Net.Mail.SmtpException
An exception of type 'System.Net.Mail.SmtpException' occurred in softwareapp.dll but was not handled in user code: 'Transaction failed. The server response was: 5.2.0 STOREDRV.Submission.Exception:OutboundSpamException; Failed to process message due to a permanent exception with message WASCL UserAction verdict is not None. Actual verdict is Suspend, ShowTierUpgrade. OutboundSpamException: WASCL UserAction verdict is not None. Actual verdict is Suspend, ShowTierUpgrade. [Hostname=LNXP265MB0668.GBRP265.PROD.OUTLOOK.COM]'
at System.Net.Mail.DataStopCommand.CheckResponse(SmtpStatusCode statusCode, String serverResponse)
at System.Net.Mail.DataStopCommand.Send(SmtpConnection conn)
at System.Net.Mail.SmtpConnection.OnClose(Object sender, EventArgs args)
at System.Net.ClosableStream.Close()
at System.Net.Mail.MailWriter.Close()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Controllers.ContactUsController.contactUsSubmitForm(ContactUsSubmitForm contactUsSubmitForm) in \Controllers\ContactUsController.cs:line 39
at Microsoft.Extensions.Internal.ObjectMethodExecutor.<>c__DisplayClass33_0.<WrapVoidMethod>b__0(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.VoidResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
код
[HttpPost()]
public void sendEmail()
{
try
{
string _sender = "[email protected]";
string _password = "password";
SmtpClient client = new SmtpClient("smtp-mail.outlook.com");
client.Port = 587;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
System.Net.NetworkCredential credentials =
new System.Net.NetworkCredential(_sender, _password);
client.EnableSsl = true;
client.Credentials = credentials;
MailMessage message = new MailMessage(_sender, "[email protected]");
message.Subject = "c sharp test email";
message.Body = "c sharp body of email";
client.Send(message); //where the code stops working and error message appears up
}
catch (Exception)
{
throw;
}
}