Network Component  Version 7.19.0
MDK Middleware for IPv4 and IPv6 Networking
Structures

Structures of the SMTP Client. More...

Structures

struct  NET_SMTP_MAIL
 SMTP Email Descriptor. More...
 
struct  NET_SMTP_MTA
 SMTP Mail Transfer Agent Descriptor. More...
 

Description

Structures of the SMTP Client.


Data Structure Documentation

◆ NET_SMTP_MAIL

struct NET_SMTP_MAIL

SMTP Email Descriptor.

NET_SMTP_MAIL contains information about the email content.

  • From, To, Cc and Bcc
    specify one or more email addresses. The address string may include optional friendly name. In this case the address name must be separated from friendly name and specified in angle brackets. Multiple addresses are separated by semicolons. Leading and trailing spaces are ignored in email address processing.

    The value of NULL indicates unspecified option. For example the value of NULL for Bcc indicates no Blind carbon copies.

    The following example specifies three To recipients (the last with no friendly name), no Cc and no Bcc:

    mail.From = "John <john@example.net>";
    mail.To = "Mary <mary@example.net>; Joe <joe@example.net>; tony@example.net";
    mail.Cc = NULL;
    mail.Bcc = NULL;
  • Subject
    specifies the subject of an email. The string might contain international characters. In this case the proper character encoding must be specified with Encoding member.
    mail.Subject = "Mail demo";
  • Message
    contains the message content, which might also contain international characters.
    mail.Message = "Hello from SMTP client!"
  • Attachment
    specifies one or more attachments to an email. The attachments are actually file names, specified in the attachment string. Multiple attachments are separated by semicolons. The value of NULL specifies no attachments. If the attachments are specified, the attachment support must also be enabled in the Configuration.

    The following example adds three attachments:

    mail.Attachment = "test.log; results.txt; M:/docs/um.pdf";
  • Encoding
    specifies the encoding type used for international characters. The value of NULL enables using default us-ascii character encoding. Other encoding types are: utf-8, iso-8859-1, etc.
    mail.Encoding = "utf-8";

Parameter for:

Data Fields
const char * Attachment Email attachment(s), can be NULL.
const char * Bcc Blind carbon copy recipient(s), can be NULL.
const char * Cc Carbon copy recipient(s), can be NULL.
const char * Encoding Default encoding type, can be NULL.
const char * From Sender address, can be NULL.
const char * Message Email message body, can be NULL.
const char * Subject Subject of email, can be NULL.
const char * To Recipient(s), can be NULL.

◆ NET_SMTP_MTA

struct NET_SMTP_MTA

SMTP Mail Transfer Agent Descriptor.

NET_SMTP_MTA contains information about the SMTP server or Mail Transfer Agent address and user credentials.

  • Address
    specifies a fully qualified domain name or an IP address of SMTP server. If the Server is specified as FQDN (ie. "smtp.gmail.com"), the IP address is resolved internally.

    The following example configures SMTP client for Gmail:

    mta.Address = "smtp.gmail.com";
    mta.Port = 0;
    mta.Flags = NET_SMTP_MTA_USETLS;
  • Port
    specifies a TCP port of the Server to connect to. If the Port number is 0, the system automatically selects the appropriate port number for communication.
    mta.Port = 25;
  • Flags
    specifies additional options for SMTP client.

    Currently only one option is defined:

    Flags Description
    NET_SMTP_MTA_USETLS Requires to use secure TLS mode (SMTPS must be enabled).
    0 Selects non-secure mode.

    The value of 0 selects non-secure mode when SMTPS is not enabled. When SMTPS is enabled, the client automatically switches to secure mode, if SMTP server supports it (explicit TLS).

    mta.Flags = 0;
  • Username
    specifies the username to be used for authentication on SMTP server.
    mta.Username = "my_username";
  • Password
    specifies the password to be used for authentication on SMTP server.
    mta.Password = "my_password";

Parameter for:

Data Fields
const char * Address Server address (FQDN or IP address)
uint16_t Flags Service control flags.
const char * Password Account password, can be NULL.
uint16_t Port Server port number, can be 0.
const char * Username Account user name, can be NULL.