Send picture over gprs, smtp, softwareSerial, received damaged !?

Hello everyone, I have a problem:
I am trying to send an email attachment with a gsm sim800l module.
I use the AT command, the gmail SMTP server and the softwareSerial lib.
everything is ok, I can send emails, sms, read an html page, send emails with a .txt file as an attachment…
but when I want to send a picture as an attachment, it arrives but degrade : the half of the photo is in good condition but the rest is broken.
the photo is stored in SPIFFS memory, its weight: 1220 bytes, but after transferring his weight: 1235 bytes:

the doc of the sim module says: “AT + SMTPFILE”
first parameter: 2 = binary file
second parameter:
third parameter: 1 = “base64”


File file =;
 Serial.println("// failed to open file for reading"); 

Serial.println("// read file from spiffs and send...");




I’m stuck, I tried a lot of different things but the picture is still broken …
I think the problem is maybe the way to send bytes, but I can not do it?
thank you in advance to all those who can help me.



If you compare the two files binary wise

Comparing files photo_ok.jpg and PHOTO_BAD.JPG
000000BD: 0A 0D
000000BE: 0B 0A
000000BF: FF 0B
000000C0: C4 FF

You see that a linefeed (0A) got converted to a CR+LF (0D, 0A)

I'm guessing that you need to convert your image to base64 before you actually write it to the module. Simply telling the module that the attached file will be base64 doesn't actually do the conversion.

thank you for your answer i will try to do that and i come back

What controller are you using, I assume ESP32...

Tom... :slight_smile:

Hi, yes i use esp32-cam

Hello, a user of the forum asked me in mp the code to send a text file as an attachment with a sim800 … I put it to him if it can help other people …

send_txt_file.ino (13.7 KB)

1 Like

Many thanks wattexi!!! Very grateful for your kind support.

Best regards,

no problem that makes me happy. I learned from people who shared their code with me, I analyze it and modify it according to my needs. I am for sharing !!! Tell me if you still need help.

1 Like

Hi Wattexi, i am trying to send picture taken by ESP32 cam to gmail using gsm module...
Can u please give me the code...
I hope you will help me with the code, Thanks in advance..

hello sorry I did not succeed I stopped at base64 encoding ... I then switched to another project

Did you google SP32 cam to gmail using gsm module.

In particular:

may help.

Tom... :slight_smile:

Hi Wattexi,could u give us your code about sending photo as attachment to gmail using sim800l?
i know u didn’t pefectly do that and that is not complete, but if u give me that i’ll be thankful

hi Wattexi, can you guide me about to send an email with sim800l? always is the same error response, 62, 63, 64, 65. Please help me.

Wasn't able to solve this one. But waiting for a solution.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.