Menu

451 5.7.3 STARTTLS is required to send mail @ office365.com / outlook.com

Bug Report
bysiu
2020-09-24
2020-09-30
  • bysiu

    bysiu - 2020-09-30
    using AegisImplicitMail;
    IConfiguration _config;
    MimeMailer _oSMTPAIMClient;
    
    public MessageSender(IConfiguration config)
            {
            public Task SendEmailAsync(string email, string subject, string message)
            {
                     _oSMTPAIMClient = new MimeMailer(
                            _config.GetValue<string>("Email:Host"), // (smtp.office365.com)
                            _config.GetValue<int>("Email:Port") //465
                        );
    
                         _oSMTPAIMClient.Credentials = new System.Net.NetworkCredential(
                            _config.GetValue<string>("Email:Username"),
                            _config.GetValue<string>("Email:Password")
                        );
                        _oSMTPAIMClient.EnableImplicitSsl = _config.GetValue<bool>("Email:EnableSsl"); // true
                _oSMTPAIMClient.SslType = SslMode.Tls;
    
                MimeMailMessage mailMsg = new MailMessage();
                mailMsg.From = new MailAddress(_config.GetValue<string>("Email:From"));
                mailMsg.IsBodyHtml = true;
                mailMsg.Subject = subject;
                mailMsg.Body = message;
                mailMsg.To.Add(email);
    
                _oSMTPAIMClient.Send(mailMsg);
    
               }
    
                private void compEvent(object sender, AsyncCompletedEventArgs e)
            {
                if (e.UserState != null)
                    Console.Out.WriteLine(e.UserState.ToString());
    
                Console.Out.WriteLine("is it canceled? " + e.Cancelled);
    
                if (e.Error != null)
                    Console.Out.WriteLine("Error : " + e.Error.Message);
            }
    }
    

    And... nevermind. When I rewrited it... it works! sorry.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.