服务器:smtp.qq.com
发送邮箱:789发发发@.qq.com
发信邮箱密码:123456
收信邮箱:123收收收@.qq.com
就是点一下按钮 就从[789发发发@.qq.com]这个邮箱发一封信给 [123收收收@.qq.com]
内容为“asd”标题“www”
代码怎么写。。。
C++smtp发送邮件怎么写
答案:2 悬赏:40 手机版
解决时间 2021-03-05 07:38
- 提问者网友:鼻尖触碰
- 2021-03-05 00:32
最佳答案
- 五星知识达人网友:由着我着迷
- 2021-03-05 02:08
我只写你SMTP这边要发的内容
socket编程的东西自己找代码去
telnet smtp.qq.com 25
EHLO localhost
AUTH LOGIN
safasdfasf < 这里是base64编码的"789发发发@.qq.com"
asdfasdasf < 这里是base64编码的"123456"
MAIL FROM: <789888@qq.com"
RCPT TO: <123sss@qq.com"
DATA
Subject: this is a test mail
this is a test mail body
line 2
line 3
. < 用一个点表示发信内容结束
socket编程的东西自己找代码去
telnet smtp.qq.com 25
EHLO localhost
AUTH LOGIN
safasdfasf < 这里是base64编码的"789发发发@.qq.com"
asdfasdasf < 这里是base64编码的"123456"
MAIL FROM: <789888@qq.com"
RCPT TO: <123sss@qq.com"
DATA
Subject: this is a test mail
this is a test mail body
line 2
line 3
. < 用一个点表示发信内容结束
全部回答
- 1楼网友:北城痞子
- 2021-03-05 03:11
你需要先配置iis smtp服务器才能正确使用。
这个很复杂的,要自己写smtp pop3 mailmessage等类。
如果只是简单的电子邮件运用,建议你用mapi操作。
mapi很简单。你只要在网上搜一下mapi.h就可以直接用了。
mapi32.dll是系统自带的。加载进来就可以了。
下面是代码,网上搜到处都是。
lhandle loghandle;
ulong res = m_mapilogon( 0,null,null,0,0,&loghandle );
cstring ss;
ss.format( "%d",res );
cstring strsubject,strbody;
strsubject = mailsubject;
strbody = mailbody;
ctime time = ctime::getcurrenttime();
cstring strtime = time.format( "%y//%m//%d//%h" );
cstring address1,address2;
address1 = user
address2 = "smtp:" + user + "@qq.com";
mapimessage message;
//subject of the mail
message.lpszsubject = strsubject.getbuffer(0);
//body of the mail
message.lpsznotetext = strbody.getbuffer(0);
message.lpszmessagetype = null;
//time sending
message.lpszdatereceived = strtime.getbuffer(0);
message.lpszconversationid = null;
message.flflags = mapi_sent;
//sender message
message.lporiginator = null;
message.nrecipcount = 1;//reciver count
mapirecipdesc reci = { 0,mapi_to,address1.getbuffer(0),address2.getbuffer(0),0,null };
//imessage::
//mapirecipdesc reci1 = { 0,mapi_to,add1.getbuffer(0),add2.getbuffer(0),0,null };
message.lprecips = &reci;
// message.lprecips = &reci1;
message.lpfiles = 0;//attachment
message.nfilecount = 0;//attachment count
int lresult = m_mapisendmail( loghandle,0,&message,0,0);
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯