Sending email over modem SIM800L

I use pppos for sending email, and when try to download body text by command “AT+SMTPBODY=20” I recieve “DOWNLOAD”. After I need send to modem only my text, for example “Test email body text” (length = 20). I recieve “ERROR”.
I tried to use pc terminal and sent all at commands manually. There were no any errors. But using mgos_pppos_run_cmds() every time I see answer “ERROR” instead of “OK” after modem answer “DOWNLOAD”.

Information from manual for modem sim800l:
sim800l_email1
sim800l_email2

My code:

struct mgos_pppos_cmd cmds[] = {
        {.cmd = "AT+EMAILCID=1"},
        {.cmd = "AT+EMAILTO=30"},
        {.cmd = "AT+SMTPCS=\"UTF-8\""},
        {.cmd = "AT+SMTPSRV=..."},
        {.cmd = "AT+SMTPAUTH=1,..."},
        {.cmd = "AT+SMTPFROM=..."},
        {.cmd = "AT+SMTPRCPT=0,0,..."},
        {.cmd = "AT+SMTPSUB=\"Test Subject\""},
        {.cmd = "AT+SMTPBODY=20"},
        {.cmd = "Test email body text"},
        {.cmd = "AT+SMTPSEND", .cb = email_cb, .cb_arg = NULL},
        {.cmd = NULL},
    };

    mgos_pppos_run_cmds(0, cmds);

In debug I see

[Sep 15 15:38:27.797] mgos_pppos.c:792        Command failed: AT+SMTPBODY=20

I tried to add “\r” “\n” “\x1A” and others to the end of my body text - there are no changes.

Whats wrong?

…UPDATED…

I tried to listen to AT commands sent by esp32:
email screen1

I don’t send command ATO! Why is it in my commands list???
And after this, my body text doesn’t send to modem!..

ATO means “Go ONLINE”, because this was probably not intended for what you are trying to do,
When you connect using PPP you provide your own TCP/IP stack, and that means your own SMTP and POP.
You are not sending mail using PPP, you are sending an email using the cell modem built in TCP/IP stack, and you are uploading your text. As I explained to you in the other post, you are interrupting PPP and the library is trying to go back to it, it thinks you are still connected and after escaping to command mode, it will go back to data mode, online.
You can:

  1. Use your own SMTP application over what mOS/Mongose provides as TCP services.
  2. Use what the IDF provides
  3. Modify the run_cmds library to your needs, or use a send-expect type library, it is just a matter of send a string and expect another as a response
1 Like

Thank you so much!..
May be you can share a library or code example of SMTP application over mos TCP services if you have?
Or can you share link for documentation or some code example for using IDF+mos? I can’t to find it on forum…

just google “smtp idf” and “smtp esp32”
I don’t know if the IDF enables/allows using the raw lwIP interface, but lwIP comes with an SMTP client (and the IDF uses a modified version of lwIP)
mOS uses an older version of Mongoose library whose API I’m not familiar with, however, any event-driven client like lwIP’s should be relatively easy to port to work with Mongoose.