文件名称:smtp发送邮件类(支持SSL)
文件大小:1.33MB
文件格式:RAR
更新时间:2013-04-17 12:57:23
smtp
//初始化邮件类 void InitEmail(C01waSendMail* m_globalEmail,String sendermail,String sender,String senderpwd,String srv,int port = 25,bool bSsl = false) { m_globalEmail->m_Auth = CPJNSMTPConnection::AuthenticationMethod::AUTH_AUTO; m_globalEmail->m_bAutoDial = true; m_globalEmail->m_bSSL = bSsl; m_globalEmail->m_sUsername = sender.c_str(); m_globalEmail->m_sAddress = sendermail.c_str(); m_globalEmail->m_sPassword = senderpwd.c_str(); m_globalEmail->m_sHost = srv.c_str(); m_globalEmail->m_nPort = port; m_globalEmail->m_sEncodingFriendly = _T("Chinese Simplified (GB2312)"); m_globalEmail->m_sEncodingCharset = _T("gb2312"); m_globalEmail->m_bMime = 1; m_globalEmail->m_bHTML = 1; m_globalEmail->m_Priority = CPJNSMTPMessage::PRIORITY::NormalPriority; m_globalEmail->m_bDSN = FALSE; m_globalEmail->m_bDSNSuccess = FALSE; m_globalEmail->m_bDSNFailure = FALSE; m_globalEmail->m_bDSNDelay = FALSE; m_globalEmail->m_bDSNHeaders = FALSE; m_globalEmail->m_bDNSLookup = FALSE; } //发送邮件 void SendEmail(const char* recvemail,const char* subject,const char* body,const char * sCC=NULL,const char * bCC = NULL,const char * attach = NULL) { //初始化邮箱 //注意释放内存 C01waSendMail *m_globalEmail = new C01waSendMail; if(strlen(m_con1.m_eamil)>0&&strlen(m_con1.m_pwd)&&strlen(m_con1.m_smtpsrv)&&m_con1.port>0) { char * p = strdup(m_con1.m_eamil); char * pp = strstr(p,"@"); if(pp>0) pp[0] = '\0'; InitEmail(m_globalEmail,m_con1.m_eamil,p,m_con1.m_pwd,m_con1.m_smtpsrv,m_con1.port,m_con1.ssl); free(p); if(subject>0) m_globalEmail->m_sSubject.Format("%s",subject); if(sCC>0) m_globalEmail->m_sCC.Format("%s",sCC); if(bCC>0) m_globalEmail->m_sBCC.Format("%s",bCC); if(body>0) m_globalEmail->m_sBody.Format("%s",body); if(attach>0) m_globalEmail->m_sFile.Format("%s",attach); if(recvemail>0) m_globalEmail->m_sTo.Format("%s",recvemail); m_globalEmail->SendEmail(); } }
【文件预览】:
sendemail
----main.cpp(1KB)
----SocMFC.h(5KB)
----resource.h(4KB)
----OpenSSLMfc.cpp(6KB)
----PJNNTLMAuth.h(3KB)
----PJNNTLMAuth.cpp(10KB)
----01waSendMail.h(1KB)
----CSendLicByEmail.cpp(3KB)
----01waSendMail.cpp(11KB)
----SocMFC.cpp(33KB)
----PJNMD5.h(7KB)
----PJNSmtp.cpp(94KB)
----iStdAfx.h(1KB)
----iStdAfx.cpp(26B)
----openssl()
--------include()
--------lib()
----PJNSmtp.h(22KB)
----OpenSSLMfc.h(4KB)