Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hii...
can any body help me by solving this ???
i made a simple email sending page...
i m getting this error...

Quote:
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Net.Mail.SmtpException: The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

Source Error:


Line 49: smtp.Credentials = new System.Net.NetworkCredential("kingofisrani@gmail.com", "bhuligayo2211");
Line 50: smtp.EnableSsl = true;
Line 51: smtp.Send(obj);
Line 52: Response.Write("msg sent successfully");
Line 53: }







my page is with 4 textbox and two button...

in my aspx.cs file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Net.Mail;
using System.Net;
using System.IO;



public partial class WebSite1_email : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_cancle_Click(object sender, EventArgs e)
    {
        Response.Redirect("home.aspx");
    }
    protected void btn_send_Click(object sender, EventArgs e)
    {

        


        MailMessage obj = new MailMessage(txt_from.Text,txt_to.Text,txt_title.Text,txt_subject.Text);
        SmtpClient smtp = new SmtpClient();
        smtp.Host = "smtp.gmail.com";
        smtp.Port = 587;


        //  your smpt sender address...

        smtp.Credentials = new System.Net.NetworkCredential("kingofisrani@gmail.com", "password");
        smtp.EnableSsl = true;
        smtp.Send(obj);
        Response.Write("msg sent successfully");
    }
}



and my .config file is like below.

XML
<?xml version="1.0"?>
<configuration>
    <system.web>
        <compilation debug="true" targetFramework="4.0">
            <assemblies>
                <add assembly="System.Web, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>
    </system.web>
    <connectionStrings>
        <add name="webconn" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Administrator\Desktop\vikas\App_Data\Database.mdf;Integrated Security=True;User Instance=True"/>
    </connectionStrings>
    <system.net>
        <mailSettings>
            <smtp from="kingofisrani@gmail.com" deliveryMethod="Network">
                <network host="smtp.gmail.com" userName="username" password="passoword" port="587" enableSsl="true" defaultCredentials="false"/>
            </smtp>
        </mailSettings>
    </system.net>
</configuration>



plzzz give me solution of this... i will be thankful to you...
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900