# Mail Client Arduino Library for ESP32 v 2.1.1
This library allows ESP32 to send Email with/without attachment and receive Email with/without attachment download via SMTP and IMAP servers.
The library was test and work well with ESP32s based module.
Copyright (c) 2019 K. Suwatchai (Mobizt).

## Tested Devices
This following devices were tested and work well.
* Sparkfun ESP32 Thing
* NodeMCU-32
* WEMOS LOLIN32
* TTGO T8 V1.8
* M5Stack ESP32
## Features
* Support Email sending with or without attachment via IMAP server.
* Support SSL/TLS and STARTTLS protocols.
* Working with SD card allows large file attachment supported or SPIFFS for small file size attachment.
* Support Email reading via search and fetch modes (with or without attachment downloads).
* Support large attachment download via SD card or SPIFFS for small file size attachment.
* Message text and its header are able to download and save to SD card or SPIFFS.
* Support Email message fetch and search via IMAP command as in RFC 3501 (depending on IMAP server implementation).
* Support Ethernet.
* Built-in Time function.
## Prerequisites
For library version 1.2.0 or newer, STARTTLS was supported and can be enable automatically when port 587 for SMTP was used or can set manually thrugh smtpData.setSTARTTLS(true) and for IMAP through imapData.setSTARTTLS(true).
## Installing
Click on **Clone or download** dropdown at the top of repository, select **Download ZIP** and save file on your computer.
From Arduino IDE, goto menu **Sketch** -> **Include Library** -> **Add .ZIP Library...** and choose **ESP32-Mail-Client-master.zip** that previously downloaded.
Go to menu **Files** -> **Examples** -> **ESP32-Mail-Client-master** and choose one from examples
## Usages
__Declaration and Initialization__
**The first thing to do to use this library.**
```C++
//1. Include ESP32 Mail Client library (this library)
#include "ESP32_MailClient.h"
//2. For sending Email, declare Email Sending data object in global scope.
SMTPData smtpData;
//Or
//For receiving Email, declare Email receiving data object in global scope.
IMAPData imapData;
//3 Setup SMTP server login credential in setup()
smtpData.setLogin("smtp.gmail.com", 587, "[email protected]", "YOUR_EMAIL_PASSWORD");
//Or
//Setup IMAP server login credential in setup()
imapData.setLogin("imap.gmail.com", 993, "[email protected]", "YOUR_EMAIL_PASSWORD");
//4 For SMTP, set some custom message header (optional)
smtpData.addCustomMessageHeader("Date: Sat, 10 Aug 2019 21:39:56 -0700 (PDT)");
smtpData.addCustomMessageHeader("Message-ID: <[email protected]>");
//5 To debug for SMTP
smtpData.setDebug(true);
//Or IMAP
imapData.setDebug(true);
//6. Send Email
MailClient.sendMail(smtpData));
//Or Receive Email
MailClient.readdMail(imapData));
```
___
__Send and Receive Email__
**Compose Email**
This library allows you to set sender, recipient, importance (priority), CC, BCC and attachment data (binary or from SD card file).
To set sender, use `smtpData.setSender` e.g. `smtpData.setSender("Jarvis", "SOME_EMAIL_ACCOUNT@SOME_EMAIL.com")`.
To set priority, use `smtpData.setPriority` e.g. `smtpData.setPriority("High")`.
To set message subject, use `smtpData.setSubject` e.g. `smtpData.setSubject("ESP32 Send Mail Test")`.
To set message text, use `smtpData.setMessage` e.g. `smtpData.setMessage("This is plain text message", false);`.
To set sender, use `smtpData.addRecipient` e.g. `smtpData.addRecipient("SOME_RECIPIENT@SOME_MAIL.com")`.
To add attachment, use `smtpData.addAttachData` e.g. `smtpData.addAttachData("test.png", "image/png", (uint8_t *)imageData, sizeof imageData);`.
When completed all required message data, sending Email `MailClient.sendMail(smtpData)`.
**Get Email**
To read or receive Email, mailbox folder should be assigned via `imapData.setFolder` e.g. `imapData.setFolder("INBOX")`.
Then set search criteria to search specified mailbox folder via `imapData.setSearchCriteria` e.g. `imapData.setSearchCriteria("UID SEARCH ALL")`.
Then set search limit to limut the memory and time usages `imapData.setSearchLimit`.
From search criteria, UID of message will be available to fetch or read.
Whit search, body message and attachment can be ignore to reduce the network data usage.
Begin receive Email `MailClient.readMail(imapData)`.
From above settings, you will get the following header information
Messsage UID via `imapData.getUID`.
Messsage ID via `imapData.getMessageID`.
Accept Language via `imapData.getAcceptLanguage`.
Content Language via `imapData.getContentLanguage`.
Sender via `imapData.getFrom`.
Sender Charset via `imapData.getFromCharset`.
Recipient via `imapData.getTo`.
Recipient Charset via `imapData.getToCharset`.
CC via `imapData.getCC`.
CC Charset via `imapData.getCCCharset`.
Date via `imapData.getDate`.
Subject via `imapData.getSubject`.
Subject Charset via `imapData.getSubjectCharset`.
In addition, by setting search criteria, the following infomation are available.
Mailbox folder count via `imapData.getFolderCount`.
Mailbox folder name via `imapData.getFolder`.
Supported flags count via `imapData.getFlagCount`.
Supported flags name via `imapData.getFlag`.
Total message in folder via `imapData.totalMessages`.
Total message from search result via `imapData.searchCount`.
Available message from search result (limited by `imapData.setSearchLimit`) via `imapData.availableMessages`.
When fetch specific message via `imapData.setFetchUID`, availability of attachment file can be determined via
`imapData.getAttachmentCount` for that message which will be automatically download by setting `imapData.setDownloadAttachment(true)`
prior to `MailClient.readMail`.
See [full examples](https://github.com/mobizt/ESP32-Mail-Client/tree/master/examples) for all features usages.
## All Supported Functions
**These are all functions available from the library and the descriptions.**
__Global functions__
**Sending Email via SMTP server.**
param *`smtpData`* - SMTP Data object to hold data and instances.
return - *`Boolean`* type status indicates the success of operation.
```C++
bool sendMail(SMTPData &smtpData);
```
**Reading Email via IMAP server.**
param *`imapData`* - IMAP Data object to hold data and instances.
return - *`Boolean`* type status indicates the success of operation.
```C++
bool readMail(IMAPData &imapData);
```
**Set the argument to the Flags for message.**
param *`imapData`* - IMAP Data object to hold data and instances.
param *`msgUID`* - The UID of message.
param *`flags`* - The flag list.
return - *`Boolean`* type status indicates the success of operation.
```C++
bool setFlag(IMAPData &imapData, int msgUID, const String &flags);
```
**Add the argument to the Flags for message.**
param *`imapData`* - IMAP Data object to hold data and instances.
param *`msgUID`* - The UID of message.
param *`flags`* - The flag list.
return - *`Boolean`* type status indicates the success of operation.
```C++
bool addFlag(IMAPData &imapData, int msgUID, const String &flags);
```
**Remove the argument from the Flags for message.**
param *`imapData`* - IMAP Data object to hold data and instances.
param *`msgUID`* - The UID of message.
param *`flags`* - The flag list.
return - *`Boolean`* type status indicates the success of operation.
```C++
bool removeFlag(IMAPData &imapData, int msgUID, const String &flags);
```
**Get the Email sending error details.**
return - *`Error details string (String object).`*
```C++
String smtpErrorReason();
```
**Get the Email reading error details.**
return - *`Error details string (String object).`*
```C++
String imapErrorReason();
```
**Init SD card with GPIO pins.**
param *`sck`* -SPI Clock pin.
param *`miso`* - SPI MISO pin.
param *`m0si`* - SPI MOSI pin.
param *`ss`* - SPI Chip/Slave
没有合适的资源?快使用搜索试试~ 我知道了~
基于ESP32的移动侦测摄像机 利用摄像头做移动侦测 同时包含自动拍摄并存至SD卡的功能.zip

共255个文件
h:60个
ino:52个
cpp:36个

1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 23 浏览量
2025-04-06
21:42:50
上传
评论
收藏 12.01MB ZIP 举报
温馨提示
【项目资源】: 适用于从基础到高级的各种项目,特别是在性能要求较高的场景中,比如操作系统开发、嵌入式编程和底层系统编程。如果您是初学者,可以从简单的控制台程序开始练习;如果是进阶开发者,可以尝试涉及硬件或网络的项目。 【项目质量】: 所有源码都经过严格测试,可以直接运行。 功能在确认正常工作后才上传。 【适用人群】: 适用于希望学习不同技术领域的小白或进阶学习者。 可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【附加价值】: 项目具有较高的学习借鉴价值,也可直接拿来修改复刻。 对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。 【沟通交流】: 有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 鼓励下载和使用,并欢迎大家互相学习,共同进步。 # 注意 1. 本资源仅用于开源学习和技术交流。不可商用等,一切后果由使用者承担。 2. 部分字体以及插图等来自网络,若是侵权请联系删除。
资源推荐
资源详情
资源评论






























收起资源包目录





































































































共 255 条
- 1
- 2
- 3
资源评论


m0_73818528
- 粉丝: 2815
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- chromedriver-linux64-141.0.7367.0(Dev).zip
- 科技平台在服务供给上常面临挑战,如何通过AI+数智应用解决?.docx
- 科技资源供给不足如何解决?如何借助AI+数智应用寻找高招?.docx
- 面对复杂多变的科技创新环境,政府应如何借助AI+数智应用培训提升应对能力?.docx
- 企业科技创新服务如何借助AI+数智应用破解资源匮乏与服务失效的难题?.docx
- 面对经济下行压力,技术转移机构如何利用AI+数智应用实现业务增长?.docx
- 面对科技平台发展挑战,政府可以采纳哪些AI+数智应用策略?.docx
- 面对科技平台可持续性挑战,有哪些创新的AI+数智应用方案?.docx
- 面对科技平台诸多困境,怎样的AI+数智应用方案能破局?.docx
- 面对市场挑战,如何借助AI+数智应用快速构建高效的技术转移产品体系?.docx
- 如何借助AI+数智应用保障科技平台的可持续发展?.docx
- 如何借助AI+数智应用推动技术转移业务升级?.docx
- 如何借助AI+数智应用提升政府科技创新管理的精细化服务?.docx
- 如何借助需求导向的AI+数智应用技转服务实现科技平台的可持续发展?.docx
- 如何利用AI+数智应用保障科技平台服务的有效性与可持续性?.docx
- 如何利用AI+数智应用保障科技平台资源丰富且服务有效?.docx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
