1# SMTP Client Example 2 3The Example is SMTP client demo. It sends and email with attachment to recipient. 4 5 6## How to use the example 7 8 9### Configure the project 10 11``` 12idf.py menuconfig 13``` 14 15* Configure Wi-Fi or Ethernet under "Example Connection Configuration" menu. See "Establishing Wi-Fi or Ethernet Connection" section in [examples/protocols/README.md](../README.md) for more details. 16 17Please set the following parameters under example config for SMTP client demo to work: 18 - Email server, port, sender's email ID, password, recipient's email ID. 19 20 21### Build and Flash 22 23Build the project and flash it to the board, then run monitor tool to view serial output: 24 25``` 26idf.py -p PORT flash monitor 27``` 28 29(Replace PORT with the name of the serial port to use.) 30 31(To exit the serial monitor, type ``Ctrl-]``.) 32 33See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. 34 35 36 37## Example output 38 39``` 40I (3212) smtp_example: Loading the CA root certificate... 41I (3212) smtp_example: Setting hostname for TLS session... 42I (3222) smtp_example: Setting up the SSL/TLS structure... 43I (3232) smtp_example: Connecting to smtp.googlemail.com:587... 44I (3542) smtp_example: Connected. 45 46220 smtp.googlemail.com ESMTP r62sm20390571pfc.89 - gsmtp 47I (3952) smtp_example: Writing EHLO to server... 48 49250-smtp.googlemail.com at your service, [182.75.158.118] 50250-SIZE 35882577 51250-8BITMIME 52250-STARTTLS 53250-ENHANCEDSTATUSCOD 54ES 55250-PIPELINING 56250-CHUNKING 57250 SMTPUTF8 58I (4262) smtp_example: Writing STARTTLS to server... 59 60220 2.0.0 Ready to start TLS 61I (4562) smtp_example: Performing the SSL/TLS handshake... 62I (5692) smtp_example: Verifying peer X.509 certificate... 63I (5692) smtp_example: Certificate verified. 64I (5692) smtp_example: Cipher suite is TLS-ECDHE-RSA-WITH-AES-128-GCM-SHA256 65I (5702) smtp_example: Authentication... 66I (5702) smtp_example: Write AUTH LOGIN 67I (6002) smtp_example: Write USER NAME 68I (6302) smtp_example: Write PASSWORD 69I (6822) smtp_example: Write MAIL FROM 70I (7132) smtp_example: Write RCPT 71I (7432) smtp_example: Write DATA 72I (8252) smtp_example: Write Content 73I (10202) smtp_example: Email sent! 74``` 75 76 77## Note: 78 - You might need to enable permission for less secure apps from email provider. This is because these email providers (e.g. gmail) insist on OAUTH authorization. 79