Пример кода для отправки почты
$fileName = 'output.pdf';
$fileatt = $pdfObj->Output('output.pdf', 'E');
$attachment = chunk_split($fileatt);
$eol = PHP_EOL;
$separator = md5(time());
$headers = 'From: Sender <[email protected]>'.$eol;
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= 'Content-Type: multipart/mixed; boundary="'.$separator.'"';
$mailMessage .= '--'.$separator.$eol;
$mailMessage .= 'Content-Type:text/html;Charset=ISO-8859-1'.$eol;
$mailMessage .= 'Content-Transfer-Encoding: 8bit'.$eol.$eol;
$mailMessage .= 'message content text'.$eol;
$eol = "\r\n";
$mailMessage .= '--'.$separator.$eol;
$mailMessage .= 'Content-Type: application/pdf; name="'.$fileName.'"'.$eol;
$mailMessage .= 'Content-Transfer-Encoding: base64'.$eol;
$mailMessage .= 'Content-Disposition: attachment; filename='.$fileName.$eol;
$mailMessage .= $attachment.$eol;
$mailMessage .= '--'.$separator.'--';
mail('[email protected]', $toEmailid, $subject, $mailMessage, $headers);
кто-нибудь может подсказать, где я не прав в приведенном выше коде?
или его проблема Thunderbird или перспективы?
Образец кода
$fileName = 'output.pdf';
$fileatt = $pdfObj->Output(SERVERPATH.'/output.pdf', 'F');
$filename = 'output.pdf';
$file = $naTmpPath.'/'.$filename;
$file_size = filesize($file);
$handle = fopen($file, "r");
$content = fread($handle, $file_size);
fclose($handle);
$attachment = chunk_split(base64_encode($content));
$eol = PHP_EOL;
$separator = md5(time());
$headers = 'From: Sender <[email protected]>'.$eol;
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= 'Content-Type: multipart/mixed; boundary="'.$separator.'"';
$mailMessage .= '--'.$separator.$eol;
$mailMessage .= 'Content-Type:text/html;Charset=ISO-8859-1'.$eol;
$mailMessage .= 'Content-Transfer-Encoding: 8bit'.$eol.$eol;
$mailMessage .= 'message content text'.$eol;
$eol = "\r\n";
$mailMessage .= '--'.$separator.$eol;
$mailMessage .= 'Content-Type: application/pdf; name="'.$fileName.'"'.$eol;
$mailMessage .= 'Content-Transfer-Encoding: base64'.$eol;
$mailMessage .= 'Content-Disposition: attachment; filename='.$fileName.$eol;
$mailMessage .= $attachment.$eol;
$mailMessage .= '--'.$separator.'--';
mail('[email protected]', $toEmailid, $subject, $mailMessage, $headers);
Других решений пока нет …