社区
C#
帖子详情
关于ssl,smtp
Marg
2006-03-09 04:35:03
我想用smtp协议发mail,可不知道怎么用c#建立一个ssl的Socket。
...全文
233
9
打赏
收藏
关于ssl,smtp
我想用smtp协议发mail,可不知道怎么用c#建立一个ssl的Socket。
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
Marg
2006-03-09
打赏
举报
回复
The .NET class library offers SSL support when you connect to an HTTP server, but unfortunately it does not offer SSL or TLS support for other Internet protocols.
lovvver(人生如此美好~) Read above sentence .
Marg
2006-03-09
打赏
举报
回复
晕,lovvver(人生如此美好~),协议我知道,我想知道怎么建立ssl的Socket
Marg
2006-03-09
打赏
举报
回复
lovvver(人生如此美好~)
3,Socket:并为实现ssl
还有GetConnection()方法在那里,
lovvver
2006-03-09
打赏
举报
回复
start/cmd/:
telnet smtp.xx.com 25
ehlo/helo
auth login
[username]
[password]
mail from
rcpt to
quit
lovvver
2006-03-09
打赏
举报
回复
1,SmtpMail:
Using System.Web.Mail; Public void sendMail
() {try {System.Web.Mail.MailMessage myMail=new MailMessage ();
MyMail.From = "myaccount@test.com"; MyMail.To =
"myaccount@test.com"; MyMail.Subject = "MailTest";
MyMail.Priority = MailPriority.Low; MyMail.BodyFormat =
MailFormat.Text; MyMail.Body = "Test";
SmtpMail.SmtpServer= "smarthost"; //your smtp server here
SmtpMail.Send (myMail); } catch (Exception e) {throw e;
}}
2.CDO:
Public void CDOsendMail () {try {CDO.Message oMsg
= new CDO.Message (); OMsg.From = "myaccount@test.com";
OMsg.To = "myaccount@test.com"; OMsg.Subject = "MailTest";
OMsg.HTMLBody = "<html><body>Test</body></html>";
CDO.IConfiguration iConfg = oMsg.Configuration;
ADODB.Fields oFields = iConfg.Fields; OFields [
"http://schemas.microsoft.com/cdo/configuration/sendusing" ] Value=2;
OFields [
"http://schemas.microsoft.com/cdo/configuration/sendemailaddress" ]
Value= "myaccount@test.com"; //sender mail oFields [
"http://schemas.microsoft.com/cdo/configuration/smtpaccountname" ]
Value= "myaccount@test.com"; //email account oFields [
"http://schemas.microsoft.com/cdo/configuration/sendusername" ] Value=
"username"; OFields [
"http://schemas.microsoft.com/cdo/configuration/sendpassword" ] Value=
"password"; OFields [
"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ]
Value=1; //value=0 (does not need to confirm) //value=1 on
behalf of the Anonymous confirmation way (to use basic on behalf of
the Basic confirmation way (clear-text) authentication. //The
configuration sendusername/sendpassword or postusername/postpassword
fields are used to specify credentials.) //Value=2 represents
the NTLM confirmation way (Secure Password Authentication in Microsoft
Outlook Express) oFields [
"http://schemas.microsoft.com/cdo/configuration/languagecode" ]
Value=0x0804; OFields [
"http://schemas.microsoft.com/cdo/configuration/smtpserver" ] Value=
"smtp.21cn.com"; OFields.Update (); OMsg.BodyPart.Charset=
"gb2312"; OMsg.HTMLBodyPart.Charset= "gb2312"; OMsg.Send
(); OMsg = null; } catch (Exception e) {throw e; }}
3,Socket:
Public void SendMail (MailMessage msg) {NetworkStream
nwstream = GetConnection (); WriteToStream (ref nwstream, "EHLO"
+ smtpHost + "\r\n"); String welcomeMsg = ReadFromStream (ref
nwstream); // implement HELO command if EHLO is unrecognized. if
(IsUnknownCommand (welcomeMsg)) {WriteToStream (ref nwstream, "HELO" +
smtpHost + "\r\n"); } CheckForError (welcomeMsg,
ReplyConstants.OK); // Authentication is used if the u/p are
supplied AuthLogin (ref nwstream); WriteToStream (ref nwstream,
"MAIL FROM: < "+ msg.From.Address +" >\r\n");
CheckForError (ReadFromStream (ref nwstream),
ReplyConstants.OK); SendRecipientList (ref nwstream, msg.To);
SendRecipientList (ref nwstream, msg.CC);
SendRecipientList (ref nwstream, msg.BCC); WriteToStream
(ref nwstream, "DATA\r\n"); CheckForError (ReadFromStream (ref
nwstream), ReplyConstants.START_INPUT); If (msg.ReplyTo.Name!
= null && msg.ReplyTo.Name.Length! = 0) {WriteToStream
(ref nwstream, "Reply-To: \ "" + msg.ReplyTo.Name + "\" < "+
msg.ReplyTo.Address +" >\r\n"); } else {WriteToStream (ref
nwstream, "Reply-To: < "+ msg.ReplyTo.Address +" >\r\n");
} if (msg.From.Name! = null && msg.From.Name.Length!
= 0) {WriteToStream (ref nwstream, "From: \ "" +
msg.From.Name + "\" < "+ msg.From.Address +" >\r\n"); } else
{WriteToStream (ref nwstream, "From: < "+ msg.From.Address +"
>\r\n"); } WriteToStream (ref nwstream, "To: "+
CreateAddressList (msg.To) +" \r\n"); If (msg.CC.Count! =
0) {WriteToStream (ref nwstream, "CC: "+ CreateAddressList
(msg.CC) +" \r\n"); } WriteToStream (ref nwstream, "Subject:
"+ msg.Subject +" \r\n"); If (msg.Priority! = null)
{WriteToStream (ref nwstream, "X-Priority: "+ msg.Priority +"
\r\n"); } if (msg.Headers.Count > 0) {SendHeaders (ref nwstream,
msg); } if (msg.Attachments.Count > 0 || msg.HtmlBody! =
null) {SendMessageBody (ref nwstream, msg); } else
{WriteToStream (ref nwstream, msg.Body + "\r\n"); }
WriteToStream (ref nwstream, "\r\n. \r\n"); CheckForError
(ReadFromStream (ref nwstream), ReplyConstants.OK);
WriteToStream (ref nwstream, "QUIT\r\n"); CheckForError
(ReadFromStream (ref nwstream), ReplyConstants.QUIT);
CloseConnection (); } private bool AuthLogin (ref
NetworkStream nwstream) {if (username! = null && username.Length
> 0 && password! = null && password.Length > 0) {WriteToStream
(ref nwstream, "AUTH LOGIN\r\n"); If (AuthImplemented
(ReadFromStream (ref nwstream))) {WriteToStream (ref nwstream,
Convert.ToBase64String (Encoding.ASCII.GetBytes
(this.username.ToCharArray ())) + "\r\n"); CheckForError
(ReadFromStream (ref nwstream), ReplyConstants.SERVER_CHALLENGE);
WriteToStream (ref nwstream, Convert.ToBase64String
(Encoding.ASCII.GetBytes (this.password.ToCharArray ())) + "\r\n");
CheckForError (ReadFromStream (ref nwstream),
ReplyConstants.AUTH_SUCCESSFUL); Return true; }} return
false; }
missQJM
2006-03-09
打赏
举报
回复
够狠
只能上CSDN
lovvver
2006-03-09
打赏
举报
回复
参考一下:
http://systemwebmail.com/
Marg
2006-03-09
打赏
举报
回复
公司除了csdn什么都上不去,麻烦贴下,谢谢
jiezhi
2006-03-09
打赏
举报
回复
参考:
http://www.mentalis.org/soft/projects/ssocket/
C++
SMTP
发送邮件(支持
SSL
,可用于使用QQ邮箱发送)
最近想用C++ 发送邮箱,发现QQ神马的,都需要
SSL
,而且QQ和126 都需要授权码来在第三方登陆,弄的很复杂,所以就下载了一个类。非常给力,试过你就知道。因为是牛人写的,这个牛人不是我,,,codeproject上的。亲测,win7 ,vs2010 无问题。
Java Socket 实现
SMTP
邮件发送,支持
SSL
/TSL
Java Socket 实现
SMTP
邮件发送,支持
SSL
/TSL
SSL
(TLS)及JSSE介绍
SSL
/ TLS是安全套接字层(Secure Sockets Layer)和 Transport Layer Security(传输层安全性)的缩写,
SSL
利用数据加密、身份验证和消息完整性验证机制,为基于TCP等可靠连接的应用层协议提供安全性保证。在互联网应用及云计算广泛使用的当今,
SSL
已经成为网络中用来鉴别站点和网页浏览者身份,成为数据加密通信传输的全球化标准。在本系列中,将介绍
SSL
/TLS的产生的历史,分层模型和安全机制介绍,介绍
SSL
协议的握手过程,并且简单介绍JSSE provider, 介绍了主要的JSSE的引擎类和列举了一个例子来增强对 JSSE实现
SSL
通信的理解。
SMTP
发送邮件程序(支持
SSL
和TLS)
SMTP
发送邮件,支持
SSL
和TLS 核心程序可以跨平台,UTF-8,base64编码,可发送附件 界面用MFC写的,只是方便测试
SMTP
支持
SSL
支持
SSL
和 密码验证的
SMTP
协议封装类..
C#
110,555
社区成员
642,563
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章