Thales' cellular IoT products business is now part of Telit Cinterion, find out more.

You are here

Telit Cinterion IoT Developer Community

Sending email

Tutorial, July 16, 2015 - 9:00am, 6742 views

Below an example how to send email using a GMAIL account. The implementation supports socket as well as SSL. In this case SMTP was used only, but the mail class supports receiving and much more.

Using the classes makes it very simple to use SMTP. A few lines of code and the email is sent.

String apn = "";// To be modified, check also if user name

// and password is needed

String mailHost = ""; // To be modified

int mailHostPort = 465;// To be modified

boolean mailHostUsesSSL = true;// To be modified

String mailUser = ""; // To be modified

String mailPass = "password"; // To be modified

String mailReceiver = "";// To be modified

SmtpClient mailClient = new SmtpClient(null, null);

mailClient.setDebug(true); // optional

try {

// hint: using gmail email address is equal

// user this might be different using other

// mail providers, mailHostPort, mailHostUsesSSL, "GPRS",

apn, null, null, null, null, 30, mailUser, mailPass);

Message msg = new Message(mailUser, mailReceiver, "Test "

+ new Date());

msg.addBodyLine("Hello!\r\nThis is a test\r\nRegards\r\nYour Gemalto Development Forum");

******** env = new ********(msg, true);


} catch (IOException e) {


} catch (MailException e) {



Download File (zip | 108.82 KB)

I don't use much mails, but I had created my own class to send emails which uses AT commands. But I must say that your example functions much better then my.

Thank you.

Markus this is great thank you. It works just as well if not better than standard AT commands. Well contained module.

I am trying to use this to modify to sending email with attachment. It is from Mail4Me yes, but it seems the MIMEDecoder only interprets the multipart content of incoming email rather than facilitating the build of mail with included attachments.

Have you tried using the API code to send attachment emails? Do you have example using this approach of your?

Many thanks.




Markus's picture