smtp not sending mail using C#

Discussion in 'ASP.NET 2.0' started by pmweb9873, Nov 23, 2006.

  1. I'm trying to send an email from my asp.net 2.0 application using C# and it doesn't generate any exceptions but the email never actually makes it to my mailbox. I can't tell if it's sending or not but it doesn't appear that it is. Is there something I need to allow in IIS in order to send email from my web server? I'm running this code on the Discountasp.net servers so localhost would resolve to the smtp server. Here is the code I'm using.

    MailMessage message = new MailMessage('[email protected]', '[email protected]');
    message.Body = 'Thank you for your payment.';
    message.Subject = 'Thank you for your payment';

    SmtpClient smtp = new SmtpClient();
    smtp.Send(message);
    Response.Write('sent message');

    And in my config file I have

    <system.net>
    <mailSettings>
    <smtp>
    <network
    host='localhost'

    />
    </smtp>
    </mailSettings>
    </system.net>

    Any help would be greatly appreciated.
     
  2. Oops, I can't belive I did that. All the email was going to my junk folder. Anyone know why it didn't go to my main folder?

    Thanks
     
  3. Bruce

    Bruce DiscountASP.NET Staff

    Hmm.. this is very difficult to troubleshoot because big mail operators (gmail, hotmail, etc.) don't tell you reason why certain mail gets dump into junk folder. I guess they don't want to reveal their spam filtering algorithm.



    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  4. I noticed the same problem today. Email sent to myyahoo email accountfrom our discountAsp.net hosted site is getting dumped into my Yahoo bulk folder. This wasn't occuring a few weeks ago. Our site is still in developement so it doesn't send out much email. My guess is one of the other sites hosted by discountAsp.netwas guilty of spamming and so now all of the other shared sites are labeled as spammers by the major Email providers.

    It might be worthwhile for one of the discountAsp.net staff to contact Yahoo and see if they can find out which emails prompted this.
     
  5. Takeshi Eto

    Takeshi Eto DiscountASP.NET Staff

  6. I tried sending mails using your code and it works fine for yahoo and gmail accept hotmail puts it into the junk folder.It is surely some filtering algorithm of thiers that causes this.

    Vikram

    DiscountASP.NET
    www.DiscountASP.NET
     

Share This Page