C# smtp response

Go To StackoverFlow.com

0

i have few question about smtp

im using this code to send mails if the host is gmail then it act diffrente:

foreach (string host in hosts)
{
    SmtpClient sc = null;
    try
    {
        if (emailDomain.ToLower() == "gmail.com")
        {
            MailSend.MailSendApp.EventLog.WriteEntry("mail to gmail.com");

            sc = new SmtpClient("smtp.gmail.com", 587);
            sc.UseDefaultCredentials = false;
            sc.DeliveryMethod = SmtpDeliveryMethod.Network;
            sc.Credentials = new NetworkCredential("UID@gmail.com", "PWD");
            sc.EnableSsl = true;
        }                                    }
        else
        {
            sc = new SmtpClient(host);

            sc.Send(mailMessage);

            break;

        }

is it possiable to get answer from smtp : 1. that the email arrived 2. if the mail exists

thanks

2012-04-04 07:12
by roy.d
nope. i guess that's why they call it e-fail - McGarnagle 2012-04-04 07:14
What is the problem with the code. In what way does it behave differently with gmail as host - Fredrik Mörk 2012-04-04 07:15
@FredrikMörk: Looks like they're trying to send as a particular Gmail user, probably to try to get around rate limiting or because their sender reputation for their SMTP gateway is poor and Gmail is rejecting emails - Eric J. 2012-04-04 07:27
one more thing about gmail is that the mail is send is never the FROM i add to emailMessage, it cant be change my FROM is the username of the UID i ask from their smt - roy.d 2012-04-04 07:34


1

If you want to receive a notification that the email has arrived you need to send the email with delivery notification options.

mailMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

If the email doesn't exists, you will get an email back to your sender address and not to your SMTP class.

In short, there's no easy way to determine these two thing purely from the SMTP class perspective.

2012-04-04 07:24
by Magnus Johansson
one more thing about gmail is that the mail is send is never the FROM i add to emailMessage, it cant be change my FROM is the username of the UID i ask from their smt - roy.d 2012-04-04 07:39


0

Back in the day you could directly query whether the email address exists on a given server (VRFY user SMTP command). Then, SPAM was born and pretty much all email servers removed that capability because spammers would use bots to query possible email recipients on each mail server to build SPAM lists.

You will still get an ordinary bounce report (email back to the reply-to address indicating that delivery failed). I use a tool called Boogie Tools to automate processing of bounce messages.

Gmail does not offer delivery or read receipts (though some email servers still optionally allow it) for similar reasons... too much abuse potential.

2012-04-04 07:23
by Eric J.
Ads