| || |
SMTP client utility
Using SEGGER middleware to send mails from your target
The SEGGER SMTP client utility is a free command line program that uses the embOS/IP SMTP client API to allow you to send mails via an SMTP server from the command line.
It is able to connect to secure SMTP servers using emSSL and send an arbitrary mail to an arbitrary recipient. An attachment file can also be added.
The utility uses only the official API provided by the embOS/IP SMTP client add-on and emSSL for sending a mail. The same functionality can be achieved on any resource constrained embedded target, using the same source code.
|Subscribe to embOS/IP software notification|
|Subscribe to emSSL software notification|
|Download embOS/IP SMTP Client Utility|
Use cases for an SMTP client
An SMTP client in your target allows you to automatically notify you in an effective way about regular notifications and/or warnings and errors. From a simple "I am still alive and this is my status" message up to a detailed report including statistics, everything is possible.
Using the SMTP client you can enable your target for the most widely accepted way of communication, using a simple and easy to handle API.
The SEGGER SMTP client utility evaluation package
A free Windows executable is available for evaluation purposes. It allows you to specify various parameters using the command line or alternate it will ask you in an interactive console for missing parameters that are mandatory.
The tool comes without any warranty and in binary form only. For a source code version, please contact us.
Getting started with the SEGGER SMTP client utility evaluation
The picture below shows the content of the evaluation package.
The SMTP client utility package consists of the following files:
The SMTP client utility itself.
A sample image file for testing the attachment feature.
The following is a short introduction to the utility including some samples on how to use it.
Evaluating the SMTP client utility
The SMTP client utility comes with several command line arguments that allow using the utility completely without interaction of the user. For a list of arguments you can start the utility with "?", "/?" or "--help".
In the picture below, a regular mail is sent using the utility. The utility is started including a "-to" argument, as otherwise it will take the FROM address that is entered interactive. Not using "-to" when starting the utility can be used in case you want to send yourself a test mail. In this case you only specify FROM (as argument or interactive) and it will be used for TO as well.
In the picture above, a mail is prepared to be sent from our generic support address to our specific embOS/IP support address. The message to send is entered line by line and confirmed by pressing [ENTER]. The complete message is sent out when only a single full stop character followed by [ENTER] is given.
The utility should respond "Mail sent" in case all parameters were O.K. and it was able to pass the mail to your SMTP server. The confirmation that this has worked as intended can be seen in the picture below.
The SMTP client utility is also able to add one or even multiple attachments to a message. To add an attachment the argument "-attach" can be used (for multiple attachments use multiple "-attach" arguments) as can be seen in the picture below.
The syntax for an attachment is as follows: -attach:"<MIME/type>Path\File.ext<FileName>"
The three placeholders have to be replaced with the following values:
The MIME type of the attachment has to be known for the sender to be able to correctly display it. For a list of MIME types please refer to one of the many resources on the internet. One can be found here: www.sitepoint.com/web-foundations/mime-types-complete-list/
The actual file on your disk that you want to attach to the mail. In our case it is in the same folder, so we do not need the complete path. Another sample would be C:\Temp\Logo.gif .
The name of the file as it is shown when receiving the mail. Files attached to mails have no context by default. They are in fact only one of possibly many multipart items in a mail. The FileName allows the receiver to identify this item as a file. By not specifying a FileName it might happen that your mail client does not show you that an attachment is present at all or does not allow you to save it easily.
Once the mail has been sent out we can confirm that attachments are working as well by having another look at our mail client.