Jul 14 2022 06:30 AM
Hi I'm used to send mail from asp.net mvc,C# code but the problem is its not work from site which start with HTTP, not any problem for send mail from site start with HTTPS. I didn't get what's the problem for this issue. I'm used below code for send mails
var hostEmail = ConfigurationExtensions.GetAppConfigValue("SMTPUserName").ToString(); var hostPassword = ConfigurationExtensions.GetAppConfigValue("SMTPPassword").ToString(); var fromEmail = ConfigurationExtensions.GetAppConfigValue("EmailFrom").ToString(); SmtpClient ss = new SmtpClient { Host = ConfigurationExtensions.GetAppConfigValue("EmailHost").ToString(), Port = ConfigurationExtensions.GetAppConfigValue<int>("smtpPort"), Timeout = 20000, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = true, EnableSsl = true, Credentials = new NetworkCredential(hostEmail, hostPassword) }; MailMessage mailMsg = new MailMessage(hostEmail, email, subject, msg) { From = new MailAddress(fromEmail, mailname), IsBodyHtml = true, DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure }; ss.Send(mailMsg);
My config code send below
<add key="EmailHost" value="smtp.office365.com" /> <add key="EnableSsl" value="true" /> <add key="smtpPort" value="587" /> <add key="SMTPUserName" value="email address removed for privacy reasons" /> <add key="SMTPPassword" value="password" /> <add key="EmailFrom" value="email address removed for privacy reasons" /> <add key="EmailUser" value="Test User" /> <add key="EmailID" value="email address removed for privacy reasons" />
Error screenshots attached below inner exception error essage fail errorfintech
Also checked this issue in different sites but not get the solution. Problem only exist while sites start in http:, not any issues in https:
Anybody know the solution ? please help me to solve this issue.
Thanks in advance
Aug 01 2022 11:28 PM
Exactly the same happened to me.
I had the following exception:
Authentication unsuccessful, SmtpClientAuthentication is disabled for the Tenant.
Visit https://aka.ms/smtp_auth_disabled for more information.
You have to allow SMTP for the account (again).
Use Exchange Online PowerShell to enable or disable SMTP AUTH on specific mailboxes :
This example enables SMTP AUTH for mailbox email address removed for privacy reasons.
Set-CASMailbox -Identity email address removed for privacy reasons -SmtpClientAuthenticationDisabled $false
Outlook/Apps failing sending mails? Microsoft has disabled SMTP (July 2022)