亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

ASP.NET 表單不發送電子郵件

ASP.NET 表單不發送電子郵件

C#
青春有我 2022-01-15 15:33:53
我正在嘗試讓表單向自己發送電子郵件,但由于某種原因它不起作用,我不知道為什么。當我提交表單時,它會顯示以下堆棧跟蹤:在 System.Net.Mail.SmtpClient.Send(MailMessage message) 在 emailform.index.send_Click(Object sender, EventArgs e) 在 C:\Users\PC\Desktop\Projects\emailform\emailform\index.aspx.cs:line 28有人有想法么?我剛開始學習C# 和 ASP.NET,所以它可能是顯而易見的。這是代碼:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="emailform.index" %><!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title></head><body>    <form id="form1" runat="server">        <br /> <br />        <table align="center" width="60%">            <tr>                <td>to:</td>                <td><asp:TextBox ID="to" runat="server" Text="[email protected]" width="60%" ></asp:TextBox></td>            </tr>            <tr>                <td>from:</td>                <td><asp:TextBox ID="from" runat="server" Text="[email protected]" Width="60%"></asp:TextBox></td>            </tr>            <tr>                <td>subject</td>                <td><asp:TextBox ID="subject" runat="server" Text="TEST" Width="60%"></asp:TextBox></td>            </tr>            <tr>                <td>body</td>                <td><asp:TextBox ID="body" runat="server" Text="this is a test message" Height="30%" Width="60%" TextMode="MultiLine"></asp:TextBox></td>            </tr>            <tr>                <td></td>                <td><asp:Button ID="send" onClick="send_Click" runat="server" Text="send" /></td>            </tr>            <tr>                <td></td>                <td><asp:Label ID="status" runat="server"></asp:Label></td>            </tr>        </table>    </form></body></html>這是C#:using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Net.Mail;namespace emailform{    public partial class index : System.Web.UI.Page    {        protected void Page_Load(object sender, EventArgs e)        {        }   
查看完整描述

3 回答

?
MM們

TA貢獻1886條經驗 獲得超2個贊

看來你的SmtpClient設置有問題。

您使用端口 25 和 SSL。

但默認情況下,端口 25 不使用 SSL 加密。請查看下一個鏈接了解詳情。

嘗試像這樣更改您的代碼:

client.EnableSsl = false;


查看完整回答
反對 回復 2022-01-15
?
炎炎設計

TA貢獻1808條經驗 獲得超4個贊

我嘗試了您的代碼,您的代碼沒有任何問題。

我認為您輸入了錯誤的網絡憑據。


查看完整回答
反對 回復 2022-01-15
?
縹緲止盈

TA貢獻2041條經驗 獲得超4個贊

圖書館也會檢查它是否是真實的電子郵件,提交真實的可能電子郵件。


查看完整回答
反對 回復 2022-01-15
  • 3 回答
  • 0 關注
  • 321 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號