SMTP Mail ?

Last post 09-28-2007 5:30 PM by phantomlove. 13 replies.

Sort Posts:

  • SMTP Mail ?

    02-15-2007, 12:57 PM

    This question might be silly.

    I was searching other's threads about sending mail from asp.net and have been looking tutorials but still can't send it.

    The codes are

    MailAddress To = new MailAddress("TowhereIwanttosend@somewhere.com");
            MailAddress From = new MailAddress(amazingsunday@sunday.com);
            MailMessage Mailer = new MailMessage(From, To);

            Mailer.Subject = "Testing";
            Mailer.Body = "Just Testing";
            SmtpClient Client = new SmtpClient();
            Client.Host = "localhost";

            Client.Send(Mailer);

            Response.Write("Successful sent");

    And This is the error

    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first i34sm4652534wxd

    What is wrong with the code? Maybe I'm not understanding what i'm doing .Will be appreciate if you help.


     

     

  • Re: SMTP Mail ?

    02-15-2007, 1:38 PM
    • Contributor
      3,399 point Contributor
    • bluemistonline
    • Member since 10-09-2002, 9:54 PM
    • Sacramento, Cali
    • Posts 676
    Is the SMTP service running on your computer? You need to install(its not by default) it to be able to send mail from your machine.
    James Hearst
    .NET Application Developer
  • Re: SMTP Mail ?

    02-15-2007, 3:05 PM
    • Star
      11,568 point Star
    • Bruce L
    • Member since 02-08-2007, 6:53 PM
    • Posts 1,935

    Nothing is wrong w/ the code from what i can see

    This error means that the SMTP server on the server housing IIS (localhost) is configured to require TLS encryption.  I am not sure what SMTP service you have installed on the server.  If it is IIS SMTP service, go to the SMTP service property -> Delivery -> Outbound Security and make sure TLS encryption is unchecked.

    Hope this helps.

    Bruce
    DiscountASP.NET - ASP.NET Hosting Experts
    Voted 2009 "Best ASP.NET Hosting" by asp.netPRO Magazine
    Win2008/IIS7.0, ASP.NET 2.0/3.5 SP1, MVC, AJAX, Silverlight, SQL 2008/2005
  • Re: SMTP Mail ?

    02-15-2007, 11:54 PM

    bluemistonline:
    Is the SMTP service running on your computer? You need to install(its not by default) it to be able to send mail from your machine.

    Yes,I guess It's running. I can see Default Virtual SMTP Server in IIS control Panel.

  • Re: SMTP Mail ?

    02-16-2007, 12:03 AM

    Yes,It's IIS SMTP service. It's already unchecked .

    By the way the error is gone and it shown Response.write("Successful sent"); but I didn't receive any mail in my Inbox,

    Do I need to do other stuff?

     

  • Re: SMTP Mail ?

    02-16-2007, 2:02 PM
    • Star
      11,568 point Star
    • Bruce L
    • Member since 02-08-2007, 6:53 PM
    • Posts 1,935

    OK.. this means that the SMTP server (localhost) accepted the email, which is good news because this no longer is an issue with your asp.net code but a server side problem.

    2 things to want to do to troubleshoot

    a) Check the SMTP queue to see if the email is there. default location: c:\inetpub\mailroot\queue

    b) Check the SMTP log to see why the email was not delivered.  Post the log if you have problem reading it.

    Bruce
    DiscountASP.NET - ASP.NET Hosting Experts
    Voted 2009 "Best ASP.NET Hosting" by asp.netPRO Magazine
    Win2008/IIS7.0, ASP.NET 2.0/3.5 SP1, MVC, AJAX, Silverlight, SQL 2008/2005
  • Re: SMTP Mail ?

    02-17-2007, 11:36 AM

    There's no email in C:\Inetpub\mailroot\Queue folder,but in Badmail .

    Sorry, I don't know where is the folder of smtp log .

  • Re: SMTP Mail ?

    02-17-2007, 1:29 PM
    • Star
      11,568 point Star
    • Bruce L
    • Member since 02-08-2007, 6:53 PM
    • Posts 1,935

    if mail is in badmail folder, there some problem w/ the SMTP setup or the to address is bad.

    Anyway, the default log file location is at c:\windows\system32\logfiles

    Bruce
    DiscountASP.NET - ASP.NET Hosting Experts
    Voted 2009 "Best ASP.NET Hosting" by asp.netPRO Magazine
    Win2008/IIS7.0, ASP.NET 2.0/3.5 SP1, MVC, AJAX, Silverlight, SQL 2008/2005
  • Re: SMTP Mail ?

    04-25-2007, 9:39 AM
    • Member
      160 point Member
    • Sonia25
    • Member since 08-13-2006, 1:57 AM
    • Posts 122

    Hi Bruce

    SMTP service property -> Delivery -> Outbound Security and make sure TLS encryption is unchecked. 

    Does  it applies to Gmail account too.Thanks

  • Re: SMTP Mail ?

    04-25-2007, 5:47 PM
    • Star
      11,568 point Star
    • Bruce L
    • Member since 02-08-2007, 6:53 PM
    • Posts 1,935

    Sonia,

    you lost me here.  What does this have to do w/ Gmail?

    Bruce
    DiscountASP.NET - ASP.NET Hosting Experts
    Voted 2009 "Best ASP.NET Hosting" by asp.netPRO Magazine
    Win2008/IIS7.0, ASP.NET 2.0/3.5 SP1, MVC, AJAX, Silverlight, SQL 2008/2005
  • Re: SMTP Mail ?

    04-26-2007, 6:24 PM
    • Member
      160 point Member
    • Sonia25
    • Member since 08-13-2006, 1:57 AM
    • Posts 122
    Never mined i was thinking of something else regarding sending mail on gmail account  .
  • Re: SMTP Mail ?

    06-09-2007, 1:58 PM
    • Member
      50 point Member
    • victorantus
    • Member since 03-28-2007, 2:21 PM
    • Posts 20

    Hi!

    I try to use smtp.gmail.com for passwordrecovery control and I get

    The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Must issue a STARTTLS command first f4sm7434685nfh...

    I think I need to enable somewhere ssl (mailClient.EnableSsl = true;). Maybe in web.config?!

     Can somebody help me?

  • Re: SMTP Mail ?

    06-09-2007, 2:26 PM
    Answer
    • Member
      50 point Member
    • victorantus
    • Member since 03-28-2007, 2:21 PM
    • Posts 20

    Found solution!

    <asp:PasswordRecovery ID="PasswordRecovery1" runat="server" OnSendingMail="PasswordRecovery1_SendingMail">

     
    protected void PasswordRecovery1_SendingMail(object sender, MailMessageEventArgs e)

    {

    SmtpClient smtpClient = new SmtpClient();

    smtpClient.EnableSsl = true;

    smtpClient.Send(e.Message);

    e.Cancel =
    true;

    }

     

    http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=163226&SiteID=1

  • Re: SMTP Mail ?

    09-28-2007, 5:30 PM
    • Member
      108 point Member
    • phantomlove
    • Member since 05-20-2007, 11:11 AM
    • Posts 129

    this works fine locally .. but when i tried hosting at http://www.vwdhosting.net i receive an error when sending mail! hope to find a solution

Page 1 of 1 (14 items)