首页 jmail发信(JMail send letters)

jmail发信(JMail send letters)

举报
开通vip

jmail发信(JMail send letters)jmail发信(JMail send letters) jmail发信(JMail send letters) This example source code or material download When you need to provide mail support functions in your VC program, you have many choices: 1) the implementation of protocols such as SMTP, POP3, MIME and...

jmail发信(JMail send letters)
jmail发信(JMail send letters) jmail发信(JMail send letters) This example source code or material download When you need to provide mail support functions in your VC program, you have many choices: 1) the implementation of protocols such as SMTP, POP3, MIME and so on from zero. This requires familiarity with a series of protocols such as RFC 821, RFC 822, RFC 1123, RFC 1652, RFC 1939, RFC2045-2049, and so on, and you can achieve all possible functions, but it takes a lot of time. 2) take advantage of some free wrapper classes, such as CSMTP, CPOP3. Although it can achieve the purpose of rapid implementation, but the function is very limited. 3) using MAPI call to support the MAPI mail sending program (such as: Outlook) to send mail, this implementation requires the client to install the specified mail sending program, not flexible enough 4) using existing components, such as: W3 JMail components to build your system, JMail components powerful, easy to complete mail sending, receiving, encryption, cluster transmission and so on. Although JMail is the most widely used application under ASP, it can work well in other languages. This article will discuss the use of W3 JMail 4.3 in VC. First, the preparation chapter Installation of 1.1 components Because the interface between JMail4.3 and the previous version has changed, so you recommend the use of version 4.3, you can download JMail 4.3 to the following web site DIMAC company VC knowledge base 1.2 fast mail sending program MINI version Let's look at the working process of the JMail component from this little example #import "jmail.dll" / / into jmail.dll, if jmail.dll is not in the project directory, you need to write the full path Void main () { CoInitialize (NULL); / / COM initialization { / / create an instance of SpeedMailer Jmail:: ISpeedMailerPtr pSpeedMailer ("JMail.SpeedMailer"); / / send mail PSpeedMailer->SendMail ("yourmail@163.com" / / email sender "Webmaster@163.com" / / recipient mailbox Theme: Hello! "/ / theme "Everybody is really good!" / / text The "smtp.163.com"); / / SMTP server } CoUninitialize (); } It's really easy to say the above code. This example uses the ISpeedMailer interface to send simple mail. I want you to see it clearly. In order to make this process seem less daunting, I omitted the exception capture and added exception capture in actual use. 1.3 exception capture The exception capture here is two different from the captured COM exception that we use. Here's a little bit of description, just to improve the integrity of this article. Look at the following code: Try { ... Send code ... } Catch (_com_error & E) { Cerr "error number: 0x", "hex" (e.Error) "endl"; Cerr "error message": "e.ErrorMessage ()" endl; Cerr "Error Description:" "e.Description ()" endl; } Two, mail send chapter The diagram below is the running effect diagram of the mail sending program attached to this article: 2.1 send mail with attachments by using IMessage interface In the front, we use ISpeedMailer to send mail, but the function is limited, "MyMailBox 1"); / / mail sender name PMessage->AddHeader ("Company", "MyCompany"); / / add any custom information Sometimes when receive mail will prompt: the sender requests a receipt to indicate that you have read this email, you want to send a receipt? To send such letters, we only need: PMessage->AddNativeHeader ("Disposition-Notification-To", "sender@domain.com"); Sender@domain.com is the return receipt mail. 2.4 mail server need to send letter authentication processing Some SMTP servers require authentication information, and you need to provide username and password at Send, for example: PMessage->Send ("username:password@mailserver.com") 2.5 do not send mail through SMTP relay server When sending a letter, we usually submit the letter to the SMTP relay server, and the SMTP relay server is responsible for the connection with the target post office, and finally submits the letter to the mail server where the recipient is located. When there is no available SMTP relay server, we can set the server name to null, for example: PMessage->Send ("," VARIANT_FALSE "); In this way, the component will query the MX record in the target domain (such as: 163.com) by DNS, and submit the letter directly to the mail server specified in the MX record. 2.6 send mail via proxy gateway The mail transfer agent (MTA) on the SMTP relay server mentioned above is the same as the SMTP agent provided by WINGATE, CPROXY and other proxy software, So the specific sending process is the same, for example: Proxy gateway address 192.16.10.11, to send letters to yourmail@yourdomain.com, the code is as follows: ...... PMessage->AddRecipient ("yourmail@yourdomain.com", "", ""); PMessage->Send ("192.16.10.11", VARIANT_FALSE); 2.7 encrypted transmission of mail and cluster sending The free version of JMail does not provide encryption and cluster sending capabilities. In order to use these functions, you need to install an unlimited JMail Standard Version or professional edition. For encrypted transport, you also need to install PGP software, such as: PGPFreeware The cluster sending function is very useful when you have thousands of clients. After you make a good template, the record in the database automatically fills in the template to generate the letter. Because the author only free version of JMail, so this function failed to try. Although the free version does not provide cluster send function, but we can only use IMessage interface combined with the database to achieve cluster sending function 2.8 common errors in sending mails When the SMTP server is set up, the error message is not available: The message was undeliverable. All servers failed to receive the message If you do not set up a SMTP server, try to send a letter with an incorrect email address, For example, webmaster@sohusohu.com will return the following error message: WSAGetLastError () returned 11001, Host not found Many SMTP servers do not support forwarding, or support forwarding, but not forwarding MAIL FROM, not a local account letter, error message: The message was undeliverable. All servers failed to receive the message Many SMTP servers do not receive external mail, such as smtp.sohu.com, so you want to send a letter to SOHU, you can not mail server, but through DNS queries the mail exchange server, or directly sets the mail server to sohumx.sohu.com. Like the SOHU mailbox, you can filter some sender mailboxes, for example, you set the sender mailbox to test@163.com, or the sender mailbox is in accordance with the recipient mailbox, When sending letters: 554: Sender address rejected:Access denied (continued...)
本文档为【jmail发信(JMail send letters)】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_196623
暂无简介~
格式:doc
大小:25KB
软件:Word
页数:7
分类:生活休闲
上传时间:2018-04-03
浏览量:20