Search code examples
emaildelphiindyindy10

Sending EMails with Indy with multiple CCs. If one is incorrect nobody recieves the mail


I currently setting up a little tool for my company that is used to send info-mails to specific user groups. But if one or more email addresses are incorrect (missing letter etc.) I get following error and the email isn't sent at all:

EIdSMTPReplyError

Requested action not taken: mailbox unavailable invalid DNS MX or A/AAAA resource record

I set up the email like this:

  • adding the first email as main recipient
  • adding all others to the cclist

Is there a way to set up the email so atleast the other recipients are getting the email?

Some Infos:

  • Delphi 7
  • Indy 10

Thanks in advance <3


Solution

  • TIdSMTP has an OnFailedRecipient event:

    type
      TIdSMTPFailedRecipient = procedure(Sender: TObject; const AAddress, ACode, AText: String;
        var VContinue: Boolean) of object;
    

    AAddress is the email address, and ACode and AText contain the error details.

    If VContinue is set to True (the default when OnFailedRecipient is assigned), the failed email is skipped and the next recipient is attempted.

    The EIdSMTPReplyError exception is raised if either:

    • OnFailedRecipient is not assigned when a recipient fails.

    • VContinue is set to False.

    • all recipients fail, regardless of OnFailedRecipient.