W55RP20 SMTP example
This is an example of acting as an SMTP client using W55RP20-EVB-Pico.
github link : https://github.com/WIZnet-ioNIC/WIZnet-PICO-SMTP-C
SMTP? (Simple Mail Transfer Protocol)
SMTP is the standard communication protocol used for sending emails over the internet. It governs the process of transmitting emails from the sender’s client to the recipient’s server. SMTP primarily handles email transmission between servers, and it is also used when a user sends an email via an email client, such as Outlook or Thunderbird.
How to test SMTP example
Setup board configuration
Setup board to W55RP20_EVB_PICO in CMakeLists.txt in WIZnet-PICO-C/ directory.
# Set board
#set(BOARD_NAME WIZnet_Ethernet_HAT)
#set(BOARD_NAME W5100S_EVB_PICO)
#set(BOARD_NAME W5500_EVB_PICO)
set(BOARD_NAME W55RP20_EVB_PICO)
#set(BOARD_NAME W5100S_EVB_PICO2)
#set(BOARD_NAME W5500_EVB_PICO2)
Setup network settings
Setup network configuration such as IP in 'w5x00_smtp.c' which is the SMTP example in 'WIZnet-PICO-SMTP-C/examples/smtp/' directory.
/* Network */
static wiz_NetInfo g_net_info =
{
.mac = {0x00, 0x08, 0xDC, 0x12, 0x34, 0x56}, // MAC address
.ip = {192, 168, 11, 2}, // IP address
.sn = {255, 255, 255, 0}, // Subnet Mask
.gw = {192, 168, 11, 1}, // Gateway
.dns = {8, 8, 8, 8}, // DNS server
.dhcp = NETINFO_STATIC // DHCP enable/disable
};
Setup smtp configuration in 'w5x00_smtp.c' in 'WIZnet-PICO-SMTP-C/examples/smtp/' directory.
/* Port */
#define PORT_STMP 25
...
static uint8_t g_smtp_target_ip[4] = {192, 168, 11, 3};
Setup smtp message configuration
Setup smtp message configuration in 'smtp.c'.
char hello[50] = "HELO localhost";
char hello_reply[] = "250";
char from[] = "admin@demo.org";
char from_reply[] = "250";
char to[] = "wiznet@demo.org";
char to_reply[] = "250";
char data_init[10] = "data";
char data_reply[] = "354";
char Cc[] = "wiznet@demo.org";
char subject[] = "Hello!WIZnet!";
char content[] = "Hello!WIZnet!";
char mime_reply[] = "250";
char mailfrom[50] = "MAIL FROM:<>";
char rcptto[50] = "rcpt to:<>";
char mime[200] = "From:\r\n";
char mime1[50] = "To:\r\n";
char mime2[50] = "Cc:\r\n";
char mime3[50] = "Subject:\r\n";
char mime4[50] = "MIME-Version:1.0\r\nContent-Type:text/plain\r\n\r\n";
char mime5[50] = "\r\n.\r\n";
Setup SMTP server
1. Setup IIS
2. Config SMTP mail
3. Download MailEnable
https://www.mailenable.com/download.asp
Check STMP port is listening.
Add user in mailbox.
Build & Run
Build project and copy w5x00_smtp.uf2 to 'RPI-RP2'.
Reset your board, you can see the network information and the email is sent.
You can check the email in the smtp server program.