How to check if the mail has been sent successfully

前端 未结 8 1199
夕颜
夕颜 2020-12-24 07:00

I am developing an Asp.Net application, where I am sending a mail to the user\'s email address, if he forgets the password.

I want to check if the mail has been sent

相关标签:
8条回答
  • 2020-12-24 07:11

    You can use the DeliveryNotificationOptions to receive a receipt.

    If you have a MailMessage object named mail, do this:

    mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnSuccess;
    
    0 讨论(0)
  • 2020-12-24 07:21

    If you're using System.Net.Mail try out

    message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.OnSuccess;
    
    0 讨论(0)
  • 2020-12-24 07:23

    if your SmtpMail.Send(message) method returns no error, it means the email was sent to the SMTP server, then you are out of your jurisdiction, that is how far you can know.

    0 讨论(0)
  • 2020-12-24 07:23

    I'am using gmail SMTP for sending mails with my program. A fake mail sent returns Ok even with SmtpFailedRecipientException trap.

    But when I check with outlook my gmail recipient I see that mail was not sent with explanation. With a subject Delivery Status Notification (Failure)

    My question is it possible to get this notificiation whitin the program.

    I found this but it's not for POP

    Notify C# Client, when SMTP Server receive a new Email

    0 讨论(0)
  • 2020-12-24 07:26

    Put the .Send(msg) method in a try catch block, and catch SmtpFailedRecipientException.

    try
    {
        mail.Send(msg);
    }
    catch (SmtpFailedRecipientException ex)
    {
        // ex.FailedRecipient and ex.GetBaseException() should give you enough info.
    }
    
    0 讨论(0)
  • 2020-12-24 07:29

    The SmtpClient.Send method will raise an Exception if there's a problem sending. But beyond getting that message to the SMTP server, there's no way to know if it makes it to the destination from there.

    0 讨论(0)
提交回复
热议问题