Network Component
Version 6.6
MDK-Professional Middleware for IP Networking
|
SMTP Client routines allow sending of e-mail notifications using a SMTP server. More...
Functions | |
bool | smtp_client_accept_authentication (const uint8_t *ip_addr) |
Accept or deny authentication requested by SMTP server. | |
netStatus | smtp_client_connect (const uint8_t *ip_addr, uint16_t port) |
Start SMTP client to send an email. | |
uint32_t | smtp_client_request (smtpClientRequest request, char *buf, uint32_t buflen, uint32_t *pvar) |
Request parameters for SMTP client session. | |
void | smtp_client_notify (smtpClientEvent event) |
Notify the user application when SMTP client operation ends. | |
enum | smtpClientRequest { smtpClientUsername, smtpClientPassword, smtpClientSender, smtpClientRecipient, smtpClientSubject, smtpClientBody } |
SMTP Client Request. More... | |
enum | smtpClientEvent { smtpClientSuccess = 0, smtpClientTimeout, smtpClientError } |
SMTP Client Events. More... | |
SMTP Client routines allow sending of e-mail notifications using a SMTP server.
Simple Mail Transfer Protocol (SMTP) is a widely used protocol for the delivery of e-mails between TCP/IP systems and users.
A SMTP Client can send e-mails to various recipients. A typical use is to send automated e-mail notifications to different e-mail addresses.
The following source code is part of the SMTP_Client_UIF.c template file. This code template enables the developer to create an application specific callback function. Also, user authentication for a specific SMTP server can be enabled or disabled:
enum smtpClientEvent |
SMTP Client Events.
Parameter for:
enum smtpClientRequest |
SMTP Client Request.
Parameter for:
bool smtp_client_accept_authentication | ( | const uint8_t * | ip_addr | ) |
Accept or deny authentication requested by SMTP server.
[in] | ip_addr | IP address of the remote SMTP server. |
The function smtp_client_accept_authentication informs the Network Component if the SMTP client should log on to a SMTP Server when sending e-mails. The Network Component library calls this function and asks the user what to do if the SMTP Server has advertised the user authentication. It is now on the user to accept the authentication.
The argument ip_addr points to a buffer containing the four octets that make up the IP address of the remote SMTP server.
You can customize the function in the file SMTP_Client_UIF.c.
Code Example
netStatus smtp_client_connect | ( | const uint8_t * | ip_addr, |
uint16_t | port | ||
) |
Start SMTP client to send an email.
[in] | ip_addr | IP address of the SMTP server. |
[in] | port | port number of SMTP server. |
The function smtp_client_connect starts the SMTP client and tries to connect to an SMTP server specified by ip_addr on the TCP port port.
The argument ip_addr points to the IP address of the SMTP server.
The argument port points to TCP port of the SMTP server.
Code Example
void smtp_client_notify | ( | smtpClientEvent | event | ) |
Notify the user application when SMTP client operation ends.
[in] | event | SMTP client notification event |
The function smtp_client_notify is called automatically when a SMTP event occurred and notifies the user application when the SMTP client operation ends.
The argument event is an SMTP client signal as defined in smtpClientEvent.
The function takes one of the following SMTP events:
Event | Description |
---|---|
smtpClientSuccess | The email has been sent successfully. |
smtpClientTimeout | SMTP Server response has timed out, and hence the SMTP client has aborted the operation. The email has not been sent. |
smtpClientError | Protocol error occurred while sending email. The email has not been sent. |
You can customize the function in SMTP_Client_UIF.c.
Code Example
uint32_t smtp_client_request | ( | smtpClientRequest | request, |
char * | buf, | ||
uint32_t | buflen, | ||
uint32_t * | pvar | ||
) |
Request parameters for SMTP client session.
[in] | request | request code. |
[out] | buf | output buffer to write the data to. |
[in] | buflen | length of the output buffer in bytes. |
[in,out] | pvar | pointer to a session's local buffer of 4 bytes.
|
The function smtp_client_request sends a client request to the SMTP server and returns the actual number of bytes written to the output buffer buf.
The argument request is an SMTP client signal as defined in smtpClientRequest.
The argument buf points to the buffer to which data are written. The argument buflen is the buf data length in bytes.
The argument pvar points to the local session buffer with a length of 4 bytes.
You can customize the function in SMTP_Client_UIF.c.
Code Example