Answer the question
In order to leave comments, you need to log in
Send email with attachment?
I found several solutions for sending, but when attaching a file, it comes empty, that is, 0 bytes in size or damaged, how to solve this?
Answer the question
In order to leave comments, you need to log in
Usually the problem is that the letter does not comply with the SMTP standard. You need to generate a multipart letter, where one of the parts will be the attached file. At a minimum, the source code of the letter should look like this:
Основные заголовки письма\r\n
Content-Type: multipart/mixed; boundary="разграничитель"\r\n
\r\n
--разграничитель\r\n
Content-Type: text/plain; charset="UTF-8";\r\n
\r\n
Основной текст письма\r\n
--разграничитель\r\n
Content-Type: правильный mime-тип, например application/octet-stream; name="имя файла"\r\n
Content-Transfer-Encoding: base64\r\n
Content-Disposition: attachment; filename="имя файла"\r\n
\r\n
Файл, закодированный в base-64\r\n
--разграничитель--\r\n
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question