关于注册时,根据填写的邮箱地址,发送给用户进行确认的程序 如题,,,请问什么思路?有相关的参考吗?谢谢啦! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以在用户注册表里添加一个字段,这个字段为GUID类型,在用户注册成功后生成一个GUID写入数据库,再把激活或者确认的地址后带着生成的GUID,当用户通过这个链接打开的时候,通过传入的GUID查找用户。 using System;using System.Text;using System.Threading;namespace Discuz.Plugin.Mail{ #region .net邮件发送程 [SmtpEmail(".net邮件发送程序", Version = "1.0", Author = "Discuz!NT ", DllFileName = "Discuz.Plugin.Mail.SysMail.dll")] public class SysMailMessage : ISmtpMail { private string _subject; private string _body; private string _from; private string _fromName; private string _recipientName; private string _mailDomain; private int _mailserverport; private string _username; private string _password; private bool _html; private string _recipient; private string ehfangUserName; public string EhfangUserName { get { return ehfangUserName; } set { ehfangUserName = value; } } private string ehfangPass; public string EhfangPass { get { return ehfangPass; } set { ehfangPass = value; } } private System.Net.Mail.Attachment attachMent; public System.Net.Mail.Attachment AttachMent { get { return attachMent; } set { attachMent = value; } } public SysMailMessage() { } /// <summary> /// 邮件主题 /// </summary> public string Subject { get { return this._subject; } set { this._subject = value; } } /// <summary> /// 邮件正文 /// </summary> public string Body { get { return this._body; } set { this._body = value; } } /// <summary> /// 发件人地址 /// </summary> public string From { get { return _from; } set { this._from = value; } } /// <summary> /// 发件人姓名 /// </summary> public string FromName { get { return this._fromName; } set { this._fromName = value; } } /// <summary> /// 收件人姓名 /// </summary> public string RecipientName { get { return this._recipientName; } set { this._recipientName = value; } } /// <summary> /// 邮箱域 /// </summary> public string MailDomain { get { return this._mailDomain; } set { this._mailDomain = value; } } /// <summary> /// 邮件服务器端口号 /// </summary> public int MailDomainPort { set { this._mailserverport = value; } get { return this._mailserverport; } } /// <summary> /// SMTP认证时使用的用户名 /// </summary> public string MailServerUserName { set { if (value.Trim() != "") { this._username = value.Trim(); } else { this._username = ""; } } get { return _username; } } /// <summary> /// SMTP认证时使用的密码 /// </summary> public string MailServerPassWord { set { this._password = value; } get { return _password; } } /// <summary> /// 是否Html邮件 /// </summary> public bool Html { get { return this._html; } set { this._html = value; } } //收件人的邮箱地址 public bool AddRecipient(params string[] username) { //this._recipient= null; this._recipient = username[0].Trim(); return true; } /// <summary> /// 发送 /// </summary> /// <returns></returns> public bool Send() {#if NET1 System.Web.Mail.MailMessage myEmail = new System.Web.Mail.MailMessage(); myEmail.From = this.From; myEmail.To = this._recipient; myEmail.Subject = this.Subject; myEmail.Body = this.Body; myEmail.Priority = System.Web.Mail.MailPriority.Normal; myEmail.BodyFormat = this.Html?System.Web.Mail.MailFormat.Html:System.Web.Mail.MailFormat.Text; //邮件形式,.Text、.Html // 通过SMTP服务器验证 myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.MailServerUserName); myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname",this.MailServerUserName); myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.MailServerPassWord); myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/postusername",this.RecipientName); myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",this.MailDomainPort); //当不是25端口(gmail:587) if(this.MailDomainPort != 25) { myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true"); } System.Web.Mail.SmtpMail.SmtpServer = this.MailDomain; try { System.Web.Mail.SmtpMail.Send(myEmail); } catch { } return true;#else System.Net.Mail.MailMessage myEmail = new System.Net.Mail.MailMessage(); Encoding eEncod = Encoding.GetEncoding("utf-8"); this.From = "[email protected]"; ///////////////你的邮件地址 myEmail.From = new System.Net.Mail.MailAddress(this.From, this.From, eEncod); //this._recipient = "[email protected]";//客户邮件地址 this.Subject = "标题"; this.Html = true; this.Body ="这里是正文" myEmail.To.Add(this._recipient); myEmail.Subject = this.Subject; myEmail.Body = this.Body; myEmail.Priority = System.Net.Mail.MailPriority.Normal; myEmail.IsBodyHtml = true; //myEmail.BodyFormat = this.Html?MailFormat.Html:MailFormat.Text; //邮件形式,.Text、.Html //添加附件 //myEmail.Attachments.Add(AttachMent); System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(); this.MailDomain = "smtp.126.com"; ///////////////需要修改 this.MailDomainPort = 25; smtp.Host = this.MailDomain; smtp.Port = this.MailDomainPort; this.MailServerUserName = xxx///////////////客户名称 this.MailServerPassWord = "55435746"; ///////////////需要修改 smtp.Credentials = new System.Net.NetworkCredential(this.MailServerUserName, this.MailServerPassWord); //smtp.UseDefaultCredentials = true; //smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; //当不是25端口(gmail:587) if (this.MailDomainPort != 25) { smtp.EnableSsl = true; } //System.Web.Mail.SmtpMail.SmtpServer = this.MailDomain; try { smtp.Send(myEmail); } catch (System.Net.Mail.SmtpException e) { string result = e.Message; return false; } return true;#endif } } #endregion} TO: esTen(仰望楼上)端口为什么是25????我在网上看到别人说新浪的是110端口是根据发件邮箱确定的吗? //当不是25端口(gmail:587) 看注释 我做SMTP客户端邮件发送器,总是发不出去!擦 关于表数据处理问题 如何在一个按钮中的事件处理函数中,调用另一个事件处理函数? 如何字节写asp.net控件,自己的 ,来个最简单的 求一个汉字转换成拼音的类 asp.net操作Excel对象出错 问个关于权限的问题,我在数据库已经预存好用户对某些网页的访问权限.需要怎么控制呢? ASP.NET 2.0里要将数据库路径写在配置文件里,怎样弄比较好? TabStrip的使用 服务器 树 tree 显示问题 20分求解答 图片列表总是有几张图片显示不出来 页面访问报错 请问ASP.NET中GirdView 能自定义显示字段吗?
using System.Text;
using System.Threading;
namespace Discuz.Plugin.Mail
{ #region .net邮件发送程
[SmtpEmail(".net邮件发送程序", Version = "1.0", Author = "Discuz!NT ", DllFileName = "Discuz.Plugin.Mail.SysMail.dll")]
public class SysMailMessage : ISmtpMail
{
private string _subject;
private string _body;
private string _from;
private string _fromName;
private string _recipientName;
private string _mailDomain;
private int _mailserverport;
private string _username;
private string _password;
private bool _html;
private string _recipient; private string ehfangUserName;
public string EhfangUserName
{
get { return ehfangUserName; }
set { ehfangUserName = value; }
}
private string ehfangPass;
public string EhfangPass
{
get { return ehfangPass; }
set { ehfangPass = value; }
}
private System.Net.Mail.Attachment attachMent;
public System.Net.Mail.Attachment AttachMent
{
get
{
return attachMent;
}
set
{
attachMent = value;
}
} public SysMailMessage()
{ } /// <summary>
/// 邮件主题
/// </summary>
public string Subject
{
get
{
return this._subject;
}
set
{
this._subject = value;
}
} /// <summary>
/// 邮件正文
/// </summary>
public string Body
{
get
{
return this._body;
}
set
{
this._body = value;
}
}
/// <summary>
/// 发件人地址
/// </summary>
public string From
{
get
{
return _from;
}
set
{
this._from = value;
}
}
/// <summary>
/// 发件人姓名
/// </summary>
public string FromName
{
get
{
return this._fromName;
}
set
{
this._fromName = value;
}
}
/// <summary>
/// 收件人姓名
/// </summary>
public string RecipientName
{
get
{
return this._recipientName;
}
set
{
this._recipientName = value;
}
} /// <summary>
/// 邮箱域
/// </summary>
public string MailDomain
{
get
{
return this._mailDomain;
}
set
{
this._mailDomain = value;
}
} /// <summary>
/// 邮件服务器端口号
/// </summary>
public int MailDomainPort
{
set
{
this._mailserverport = value;
}
get
{
return this._mailserverport;
}
}
/// <summary>
/// SMTP认证时使用的用户名
/// </summary>
public string MailServerUserName
{
set
{
if (value.Trim() != "")
{
this._username = value.Trim();
}
else
{
this._username = "";
}
}
get
{
return _username;
}
} /// <summary>
/// SMTP认证时使用的密码
/// </summary>
public string MailServerPassWord
{
set
{
this._password = value;
}
get
{
return _password;
}
} /// <summary>
/// 是否Html邮件
/// </summary>
public bool Html
{
get
{
return this._html;
}
set
{
this._html = value;
}
} //收件人的邮箱地址
public bool AddRecipient(params string[] username)
{
//this._recipient= null;
this._recipient = username[0].Trim(); return true;
} /// <summary>
/// 发送
/// </summary>
/// <returns></returns>
public bool Send()
{
#if NET1
System.Web.Mail.MailMessage myEmail = new System.Web.Mail.MailMessage();
myEmail.From = this.From;
myEmail.To = this._recipient;
myEmail.Subject = this.Subject;
myEmail.Body = this.Body;
myEmail.Priority = System.Web.Mail.MailPriority.Normal;
myEmail.BodyFormat = this.Html?System.Web.Mail.MailFormat.Html:System.Web.Mail.MailFormat.Text; //邮件形式,.Text、.Html // 通过SMTP服务器验证
myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.MailServerUserName);
myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpaccountname",this.MailServerUserName);
myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.MailServerPassWord);
myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/postusername",this.RecipientName);
myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",this.MailDomainPort); //当不是25端口(gmail:587)
if(this.MailDomainPort != 25)
{
myEmail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");
}
System.Web.Mail.SmtpMail.SmtpServer = this.MailDomain; try
{
System.Web.Mail.SmtpMail.Send(myEmail);
}
catch
{
}
return true;
#else System.Net.Mail.MailMessage myEmail = new System.Net.Mail.MailMessage();
Encoding eEncod = Encoding.GetEncoding("utf-8");
this.From = "[email protected]"; ///////////////你的邮件地址
myEmail.From = new System.Net.Mail.MailAddress(this.From, this.From, eEncod);
//this._recipient = "[email protected]";//客户邮件地址
this.Subject = "标题";
this.Html = true;
this.Body ="这里是正文" myEmail.To.Add(this._recipient);
myEmail.Subject = this.Subject;
myEmail.Body = this.Body;
myEmail.Priority = System.Net.Mail.MailPriority.Normal;
myEmail.IsBodyHtml = true;
//myEmail.BodyFormat = this.Html?MailFormat.Html:MailFormat.Text; //邮件形式,.Text、.Html
//添加附件
//myEmail.Attachments.Add(AttachMent);
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
this.MailDomain = "smtp.126.com"; ///////////////需要修改
this.MailDomainPort = 25;
smtp.Host = this.MailDomain;
smtp.Port = this.MailDomainPort;
this.MailServerUserName = xxx///////////////客户名称
this.MailServerPassWord = "55435746"; ///////////////需要修改
smtp.Credentials = new System.Net.NetworkCredential(this.MailServerUserName, this.MailServerPassWord);
//smtp.UseDefaultCredentials = true;
//smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network; //当不是25端口(gmail:587)
if (this.MailDomainPort != 25)
{
smtp.EnableSsl = true;
}
//System.Web.Mail.SmtpMail.SmtpServer = this.MailDomain; try
{
smtp.Send(myEmail);
}
catch (System.Net.Mail.SmtpException e)
{
string result = e.Message;
return false;
}
return true;
#endif
}
}
#endregion}
esTen(仰望楼上)端口为什么是25????
我在网上看到别人说新浪的是110
端口是根据发件邮箱确定的吗?
擦