question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sending Emails Error

See original GitHub issue

I am trying to send emails with the code below from localhost using the version 3.3.2 (.Net Core):

public class SingleEmailSenderJob : BackgroundJob<SingleEmailSenderJobArgs>, ITransientDependency
   {
       private readonly IRepository<User, long> _userRepository;
       private readonly IEmailSender _emailSender;

       public SingleEmailSenderJob(IRepository<User, long> userRepository, IEmailSender emailSender)
       {
           _userRepository = userRepository;
           _emailSender = emailSender;
       }

       [UnitOfWork]
       public override void Execute(SingleEmailSenderJobArgs args)
       {
           _emailSender.Send(args.ToEmailAddress, args.Subject, args.Body);
       }
   }

Everything else is pretty standard as per the docs. The Email settings in the Db are:

Abp.Net.Mail.DefaultFromAddress: something17@gmail.com
Abp.Net.Mail.DefaultFromDisplayName: Core App
Abp.Net.Mail.Smtp.Host: smtp.gmail.com
Abp.Net.Mail.Smtp.Port: 587
Abp.Net.Mail.Smtp.UserName: something17@gmail.com
Abp.Net.Mail.Smtp.Password: Password123#
Abp.Net.Mail.Smtp.Domain: http://localhost:21021
Abp.Net.Mail.Smtp.EnableSsl: True
Abp.Net.Mail.Smtp.UseDefaultCredentials: False

However, sending fails with this error:

System.Net.Mail.SmtpException occurred
  HResult=0x80131500
  Message=The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at
  Source=<Cannot evaluate the exception source>
  StackTrace:
   at System.Net.Mail.MailCommand.CheckResponse(SmtpStatusCode statusCode, String response)
   at System.Net.Mail.MailCommand.Send(SmtpConnection conn, Byte[] command, MailAddress from, Boolean allowUnicode)
   at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, Boolean allowUnicode, SmtpFailedRecipientException& exception)
   at System.Net.Mail.SmtpClient.Send(MailMessage message)
   at Abp.Net.Mail.Smtp.SmtpEmailSender.SendEmail(MailMessage mail)
   at Abp.Net.Mail.EmailSenderBase.Send(String to, String subject, String body, Boolean isBodyHtml)
   at CoreLotto.Notifications.SingleEmailSenderJob.Execute(SingleEmailSenderJobArgs args) in C:\Users\user\Desktop\Production Apps\CoreLotto\src\CoreLotto.Core\Notifications\SingleEmailSenderJob.cs:line 27
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Abp.Domain.Uow.UnitOfWorkInterceptor.PerformSyncUow(IInvocation invocation, UnitOfWorkOptions options)
   at Castle.DynamicProxy.AbstractInvocation.Proceed()

Please does anyone know what I am doing wrong?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
coommarkcommented, Nov 24, 2017

Ha! Well, I guess the problem was with gmail. I tinkered with security settings on Gmail, whatever it was I did worked. Now it is sending okay using _emailSender.Send(args.ToEmailAddress, args.Subject, args.Body); Let me close this. Thanks @acjh for the patience man. Really digging Abp. Guess for .net development, I am going to always swear by it. Saves lots of work.

1reaction
acjhcommented, Nov 24, 2017

Do you know why that is a fix? Does it still work if you comment out the ServicePointManager line?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot send emails: How to fix email sending issues
Cannot send emails: How to fix email sending issues · Check your internet connection. · Check your SMTP server details. · Verify all...
Read more >
Emails fail to send / Sending error/ Emails stay in drafts
How to fix · Make sure you can successfully send an email from your web mail. · Try sending an email, with your...
Read more >
Error occurs when you send or receive an email message ...
Error occurs when you send or receive an email message in Outlook or Outlook Express.
Read more >
Sent email in Outlook.com comes back "delivery failed"
This message means that the recipient has too many messages in their inbox. Many email systems prevent users from receiving any new mail...
Read more >
If you can't send email on your iPhone or iPad
If you can't send email from the Mail app on your iPhone or iPad, there are a few things you can try.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found