S
S
Sviterast2016-05-05 10:31:11
PHP
Sviterast, 2016-05-05 10:31:11

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

1 answer(s)
R
Rsa97, 2016-05-05
@Sviterast

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

Blank lines after the heading and subheadings are required.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question