邮箱不可用。 服务器响应为: not local host live.cn, not a gateway
这个是出现的错误的提示

解决方案 »

  1.   

    using System;
    using System.Data;
    using System.Configuration;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Net.Mail;
    using System.IO;
    using System.Collections.Generic;
    using System.Net;/// <summary>
    ///Class1 的摘要说明
    /// </summary>
    public class Mail
    {
        static string strHost = String.Empty;
        static string strAccount = String.Empty;
        static string strPwd = String.Empty;
        static string strFrom = String.Empty;    /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="to">接收方邮件地址</param>
        /// <param name="title">邮件标题</param>
        /// <param name="content">邮件正文内容</param>
        public static bool sendmail(string to, string title, string content)
        {
            strHost = "mail.shjry.com";   //STMP服务器地址
            strAccount = "shjry";       //SMTP服务帐号
            strPwd = "340827";       //SMTP服务密码
            strFrom = "[email protected]"; //发送方邮件地址        SmtpClient _smtpClient = new SmtpClient();
            _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
            _smtpClient.Host = strHost; ;//指定SMTP服务器
            _smtpClient.UseDefaultCredentials = true;
            _smtpClient.Credentials = new System.Net.NetworkCredential(strAccount, strPwd);//用户名和密码        //如果上面的不能成功可以将发送方式该为下面这一句
                   MailMessage _mailMessage = new MailMessage(strFrom, to);
            _mailMessage.Subject = title;//主题
            _mailMessage.Body = content;//内容
            _mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//正文编码
            _mailMessage.IsBodyHtml = true;//设置为HTML格式
            _mailMessage.Priority = MailPriority.High;//优先级        try
            {
                _smtpClient.Send(_mailMessage);
                return true;
            }
            catch(Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
    }
      

  2.   

    using System;
    using System.Configuration;
    using System.Data;
    using System.Linq;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Xml.Linq;
    using System.Net.Mail;
    using System.Net;public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {    }    protected void emailBtn_onclick(object sender, EventArgs e)
        {
            Mail.sendmail("[email protected]", "12", "调试内容");
            Response.Write("<script>alert('发送成功');</script>");
            
        }    
    }
       
      

  3.   

    <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>无标题页</title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
          <asp:Button ID="emailBtn" Text="发送邮件" runat="server" OnClick="emailBtn_onclick" />
        
        </div>
        </form>
    </body>
    </html>
      

  4.   

     strHost = "mail.shjry.com";   这个问题  是你自己的邮件服务器吗?
      

  5.   

    问题是strHost="mail.shjry.com" 是我自己的,如果把strFrom 改成 [email protected]  把to 改成[email protected]能发送成功,但这样没有意思啊
      

  6.   

    如果我用smtp.163.com,或者smtp.qq.com都不可以的
      

  7.   

    好像是SmtpClient _smtpClient = new SmtpClient();
            _smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;//指定电子邮件发送方式
            _smtpClient.Host = strHost; ;//指定SMTP服务器我记得复制时IP那种的
      

  8.   

      strHost = "mail.shjry.com";   //STMP服务器地址
            strAccount = "shjry";       //SMTP服务帐号 ···据我所知道,用户名要带上邮箱后缀的!
            strPwd = "340827";       //SMTP服务密码
            strFrom = "[email protected]"; //发送方邮件地址
      

  9.   

    例如
     SmtpClient client = new SmtpClient("58.214.9.54");
      

  10.   

    strAccount = "shjry";      写邮箱全称试试