SmtpTransientErrorOccurred Event
Occurs on a transient SMTP error which can be ignored because at least one fail-over SMTP server hasn't been tried yet.

Namespace: MailBee.SmtpMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
public event SmtpTransientErrorOccurredEventHandler TransientErrorOccurred


Type: MailBee.SmtpMailSmtpTransientErrorOccurredEventHandler

This event may not occur if only a single SMTP server is available for sending to the domain for which sending has failed.

This event lets the application decide what to do when the current SMTP server reports that it cannot deliver your message to the given e-mail address. You can either let MailBee try another server or stop trying the current message. This choice is helpful because the library itself cannot determine if sending should be stopped. Two kinds of transient errors exists:

  • Temporary errors which can be fixed if another server is tried (e.g. the current server is experiencing temporary failure).
  • Temporary errors which occur by purpose (such as "try again later" grey-listing). You need to try again later, simply trying another server won't help.

Unfortunately, there is no distinction between SMTP codes for these errors. Thus, the app or even the user will have to make choice based on their preferences (or you can examine the human-readable response from the server although this is not reliable). If you subscribe to this event, you can control this behavior. If you don't subscribe, MailBee will retry if there is at least one more SMTP relay server left (in case if you're sending via SMTP relay servers) and won't retry in case of direct send.

This default behavior is a general recommendation: you should retry in case of relay SMTP servers (SmtpServers) and don't retry if you're using direct send (MX lookup) so that SmtpServers is empty. SMTP servers obtained via MX lookup often use greylisting so in most cases retrying with another MX will make your IP address getting banned. If, however, your situation is different, you can use this event to adjust the default behavior.

This sample sends enables retries of SMTP MX servers (if there are multiple available for the given recipient's e-mail domain) in case of direct sends.
using System;
using MailBee;
using MailBee.SmtpMail;

class Sample
    // TransientErrorOccurred event handler.
    private static void OnTransientErrorOccurred(object sender,
        SmtpTransientErrorOccurredEventArgs e)
        Console.WriteLine("SMTP error code: " + e.Reason.ErrorCode);
        Console.WriteLine("Server response: " + e.Reason.ResponseString);
        e.Continue = true; // Enable SMTP MX retries.

    // The actual code.
    static void Main(string[] args)
        Smtp mailer = new Smtp();

        // Logging is cool for debugging.
        mailer.Log.Enabled = true;
        mailer.Log.Filename = @"C:\Temp\log.txt";

        // Get DNS servers from the system.

        // Subscribe to the event.
        mailer.TransientErrorOccurred +=
            new SmtpTransientErrorOccurredEventHandler(OnTransientErrorOccurred);

        // Prepare and send the message
        mailer.To.AsString = "";
        mailer.From.Email = "";
        mailer.Subject = "Test message";
See Also