Clever Mailer for RAD Studio |
||
AbstractThe algorithm of the mailer program is simple:
Lets go ahead and consider each of these steps in details. Read configuration informationThe program uses a special configuration file in "ini" format. So we can use the TIniFile class for loading this information:
The message body can be represented in text, HTML or both formats. Each message body part is loaded from the file on the disk. The recipient list is loaded from the file as well.
You may need to substitute the name of the recipient to the message body before sending. The TclEmailAddressItem class from Clever Internet Suite allows you to extract the name part from the fully qualified email address information:
Set up the DKIM componentThe DKIM component requires the following information for signing the message: domain, selector and a private key. This information is loaded from the configuration file and from the specified key file in the "pem" format. The detailed description for the domain and selector parameters can be found in the DKIM standard RFC 6376
The key information represents the private part of the public / private key pair that is specific to the sender's domain. If you don't have a key, you can generate it with the DKIM component from the Clever Internet Suite library. A sample of this functionality can be found in the DkimSign demo. You can download it at Clever Internet Suite Download Loop through the recipient list and send mailAfter the whole data is ready and the components are configured, you can loop through the recipient list and send mail to each of them. There is one important moment: you need to check whether the message has been aready sent before starting the process. Otherwise, the message may be sent twice or more times.
Write reportThe sending status can be stored in a report file for further analyzing. Note, the sending status may differ from the delivery status. The sending status indicates that the message was sent successfully at the client side. The most of email services may initially accept the email message, but not deliver to the recipient's mailbox. There may be different reasons why the message is not delivered: email filtering, mailbox unavailable, mailbox is full, etc. In such a case, you receive the non-delivery report. This report is sent by the email service to the sender's mailbox. The analysis of these non-delivery reports is out of scope of this article. We will consider this task in the next article. This functionality may be implemented with the BounceChecker component of the Clever Internet Suite library.
Supported compiler versionsClever Mailer for RAD Studio can be used in RAD Studio XE3 and higher, including RAD Studio 10.1 Berlin. If you modify the sources and remove all references to the RAD Studio namespaces in the 'uses' sections, you can use the library in older versions of RAD Studio, CodeGear or Borland Delphi. Download source codeThe program is distributed under the terms of the GNU Lesser General Public License version 3, GNU General Public License The current version of Clever Mailer for RAD Studio needs for the non-free library Clever Internet Suite. This is a drawback, and we suggest the task of changing the program so that it does the same job without the non-free library. Anyone who thinks of doing substantial further work on the program, first may free it from dependence on the non-free library. The class structure allows you to easily replace the Clever Internet Suite MailMessage, Smtp and Dkim components with any other third-party free and non-free software.
Please feel free to Contact us if you need any assistance.
Sergey Shirokov
|