如何解决与asp.net发送电子邮件相关的错误? [英] how to solve this error related to sending email by asp.net ?

查看:89
本文介绍了如何解决与asp.net发送电子邮件相关的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hii ...

任何人都可以帮我解决这个问题???

i做了一个简单的电子邮件发送页面...

im得到这个错误...



hii...
can any body help me by solving this ???
i made a simple email sending page...
i m getting this error...

引用:

SMTP服务器需要一个安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。了解更多信息



描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息:System.Net.Mail.SmtpException:SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。了解更多信息



来源错误:





第49行:smtp .Credentials = new System.Net.NetworkCredential(kingofisrani@gmail.com,bhuligayo2211);

第50行:smtp.EnableSsl = true;

第51行:smtp.Send(obj);

第52行:Response.Write(msg发送成功);

第53行:}

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: }















我的页面有4个文本框和两个按钮...



在我的 spx.cs 文件中。










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");
    }
}







和我的 .config 文件如下所示。






and my .config file is like below.

<?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给我这个解决方案......我会很感激对你...




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

推荐答案

这篇关于如何解决与asp.net发送电子邮件相关的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆