Home General

SMTP

edited January 2012 in General
Hello

Delphi XE, Windows7 64 bit and RBuilder 14.2.

Utilizing the show email error demo I can capture SMTP errors if the sendto
email address has a domain error, i.e. emailmailbox@comcast333.net rather
than emailmailbox@comcast.net. However, if the domain name is correct, but
the mailbox is incorrect I do not receive an error.

a) Does anyone know where in the documentation I can find exactly what SMTP
error messages are displayed?
b) Is there a mechanism in RBuilder to check the mailbox portion of the
email address prior to sending the message?

TIA

John

Comments

  • edited January 2012
    Hi John,

    I believe this is a function of the receiving server. In my testing
    with our own server, an incorrect email mailbox returns the SMTP 550
    error with the message "Invalid mailbox". It looks like the TidSMTP
    object has a Verify routine that you could use to find out if a mailbox
    is valid before sending. You can access the TidSMTP object using the
    IndySMTP property of the TppSMTPIndy object.

    TppSMTPIndy(TppEmail(ppReport1.Email).SMTP).IndySMTP

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2012
    Nico

    Obviously, to validate an email address a domain name server must be
    accessed. This access implies certain permissions have to be granted by the
    name server to the query. I am uncertain amount how the code that you
    suggested addresses these concerns. I have tried placing the code that you
    suggested into two different locations to try and validate a email address.
    Both scenarios failed and are shown below. I would greatly appreciate any
    additional suggestions that you have. .

    Scenario 1:

    The showmessage dialog shown below is placed immediately after completing
    all of the email settings and prior to sending the email. When I do this
    and step through the code, I immediately go from the verify command line to
    the finally block and the message that is displayed is "connection closed
    gracefully".

    // must follow assignment of tempIOHandler
    if FieldByName('SMTP_TLS').AsBoolean = True then
    begin
    TppSMTPIndy(tempEmail.SMTP).IndySMTP.UseTLS := utUseExplicitTLS;
    end
    else
    begin
    TppSMTPIndy(tempEmail.SMTP).IndySMTP.UseTLS := utNoTLSSupport;
    end;

    MessageDlg(''Result of verification = ' +
    TppSMTPIndy(tempEmail.SMTP).IndySMTP.Verify(tempToEmailAddress),
    mtInformation, [mbOK], 0);

    tempEmailError := False;
    tempEmailStatus := 'Sending';
    ppReport1.SendMail;

    finally
    tempIOHandler.Free;
    end;

    Scenario 2:

    As an alternative to scenario 1: I tried to capture the results of the
    verify function with the code below, but received the following error.

    Project PLOffMgr.exe raised exception class EidSMTPReplyError with message
    'ect' ESMTP server ready


    procedure TRBReportRequestLetter2.EmailStatusChangeEvent(Sender: TObject);
    var
    tempError: String;
    begin
    if TppEmail(ppReport1.Email).SMTP.Status = 'Connected. then
    begin
    MessageDlg('Result of verification = ' +
    TppSMTPIndy(tempEmail.SMTP).IndySMTP.Verify(tempToEmailAddress),
    mtInformation, [mbOK], 0);
    end;
    end;

    TIA

    John

  • edited January 2012
    Hi John,

    The code I gave simply shows how to directly access the TidSMTP object
    so you, the developer, can manipulate it as needed.

    ReportBuilder tries to keep a hands-off approach with Indy. It simply
    creates an Indy SMTP object, gives it the minimal information needed,
    and lets it go from there. Any further processing, manipulation, or
    info needs to be done by you using the property I mentioned.

    Generally the best approach is to get it working without ReportBuilder
    first using only Delphi and Indy components. Then using the same
    settings move back to the RB Indy plugin.

    That being said, I do not believe you will ever be able to get the
    information you want from a large email server such as comcast.net.
    Large servers have strict security in place to block this very action to
    prevent spammers from being able to simply find valid email addresses.

    http://stackoverflow.com/questions/5449816/check-email-existence-using-delphi-with-indy-or-any-other-components-tools-for-d

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.