This section contains APIs used for communication through SMTP protocol. 

rsi_smtp_client_create

Prototype int32_t rsi_smtp_client_create(uint8_t flags,uint8_t *username,uint8_t *password, uint8_t *from_address,uint8_t *client_domain,uint8_t auth_type,uint8_t *server_ip, uint32_t port);
Input Arguments uint8_t flags: To select IPv6 version, a bit in flags is set. By default IP version is set to IPV4. RSI_IPV6 – BIT(0) To select IPv6 version

uint8_t *username: Username for authentication Should be NULL terminated string

uint8_t *password: Password for authentication

Should be NULL terminated string

uint8_t *from_address: sender’s addres Should be NULL terminated string

uint8_t *client_domain: domain name of the client Should be NULL terminated string

uint8_t auth_type: client authentication type

1 – SMTP_CLIENT_AUTH_LOGIN

3 – SMTP_CLIENT_AUTH_PLAIN

uint8_t *server_ip: SMTP server IP address

IPv4 address – 4 Bytes  hexa-decimal,

IPv6 address – 16 Bytes  hexa-decimal

uint32_t port: SMTP server TCP port

Note : SMTP server port is configurable on non standard port also

 

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015,0xBBA5,0xBB21,0x003E,0xBBB2
  • Please refer Error! Reference source not found. for description of above error codes.
Description This API is used to create an smtp client.This will initialize the client with given configuration.
Example Usage rsi_smtp_client_create((uint8_t )FLAGS, (uint8_t*)USERNAME,(uint8_t*)PASSWORD,(uint8_t*)FROM_ADDRESS,(uint8_t*)CLIENT_DOMAIN, (uint8_t)AUTH_TYPE, (uint8_t *)&server_ip, (uint16_t)SMTP_PORT);

rsi_smtp_client_mail_send_async

Prototype int32_t rsi_smtp_client_mail_send_async(uint8_t *mail_recipient_address,uint8_t priority,uint8_t *mail_subject,uint8_t *mail_body,uint16_t mail_body_length,void(*smtp_client_mail_response_handler)(uint16_t status,const uint8_t cmd_type));
Input Arguments uint8_t *mail_recipient_address: mail recipient address

uint8_t priority: priority level at which mail is delivered

1 – RSI_SMTP_MAIL_PRIORITY_LOW

2- RSI_SMTP_MAIL_PRIORITY_NORMAL

4 – RSI_SMTP_MAIL_PRIORITY_HIGH

uint8_t *mail_subject: Subject line text Null terminated string.

uint8_t *mail_body: mail message

uint16_t mail_body_length: length of mail body

Note : Maximum length of mail_recipient_address, mail_subject, mail_body together is 1024 bytes

 

void *smtp_client_mail_response_handler: callback when asynchronous response comes for the sent mail

parameters: status , cmd

status:status code

cmd_type: sub command type

Note : If status in callback is nonzero, sub command type is in 6th byte of descriptor

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015,0x003E,0xBBA5,0xBBA3,0xBBA0,0xBBA1,0xBBA2,OxBBA4,OxBBA6,0xBBA7,0xBBA8,0xBBA9,0xBBAA,0xBBAB,0xBBAC,0xBBAD,0xBBAE,0xBBAF,0xBBB0,0xBBB1,0xBBB2
  • Please refer Error! Reference source not found. for description of above error codes.
Description This API is used to send mail to the recipient from the smtp client.
Example Usage rsi_smtp_client_mail_send_async((uint8_t*)MAIL_RECIPIENT_ADDRESS,(uint8_t)PRIORITY,(uint8_t*)MAIL_SUBJECT, (uint8_t*)MAIL_BODY,strlen(MAIL_BODY),rsi_smtp_client_mail_send_response_handler);

rsi_smtp_client_delete_async

Prototype int32_t rsi_smtp_client_delete_async(void(*smtp_client_mail_response_handler)(uint16_t status,const uint8_t cmd_type));
Input Arguments void(*smtp_client_mail_response_handler): callback when asynchronous response comes for the delete request

parameters: status , cmd

status:status code

cmd_type: sub command type

Return Value
  • On Success :  0
  • On Failure   :
  • if return value is less than 0
  • -3 : Command given in wrong state
  • -4 : Buffer not available to serve the command
  • if return value is greater than 0
  • 0x0021,0x002C,0x0015
  • Please refe Error Codes for description of above error codes.

 

Description This API is used to delete the smtp client.
Example Usage rsi_smtp_client_delete_async(rsi_smtp_client_delete_response_handler);