Portál AbcLinuxu, 16. července 2025 07:49
<.php $attachment = chunk_split(base64_encode(file_get_contents("priloha.pdf"))); //define the body of the message. ob_start(); //Turn on output buffering .> --PHP-mixed-<.php echo $random_hash; .> Content-Type: multipart/alternative; boundary="PHP-alt-<.php echo $random_hash; .>" --PHP-alt-<.php echo $random_hash; .> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit <.php echo "Tu je text emailu."; .> --PHP-alt-<.php echo $random_hash; .>-- --PHP-mixed-<.php echo $random_hash; .> Content-Type: application/pdf; name="<.php echo "priloha.pdf"; .>" Content-Transfer-Encoding: base64 Content-Disposition: attachment <.php echo $attachment; .> --PHP-mixed-<.php echo $random_hash; .>-- <.php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, "=.UTF-8.B.".base64_encode($subject).".=", $message, $headers ); .>Hlavne na gmail.com a yahoomail sa popríchode takéhoto emailu stáva, že je to chybne interpretované a príloha aj s textom sa zobrazí v textovej časti emailu, teda príloha nie je ako príloha. v čom tam je problém?
<.php $headers .= "\r\nContent-Type: multipart/mixed; boundary=PHP-mixed-".$random_hash; $attachment = chunk_split(base64_encode(file_get_contents("priloha.pdf"))); //define the body of the message. ob_start(); //Turn on output buffering .> --PHP-mixed-<.php echo $random_hash; .> Content-Type: multipart/alternative; boundary="PHP-alt-<.php echo $random_hash; .>" --PHP-alt-<.php echo $random_hash; .> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit <.php echo "text mejlu"; .> --PHP-alt-<.php echo $random_hash; .>-- --PHP-mixed-<.php echo $random_hash; .> Content-Type: application/pdf; name="<.php echo "priloha.pdf"; .>" Content-Transfer-Encoding: base64 Content-Disposition: attachment <.php echo $attachment; .> --PHP-mixed-<.php echo $random_hash; .>-- <.php //copy current buffer contents into $message variable and delete current output buffer $message = ob_get_clean(); //send the email $mail_sent = @mail( $to, "=.UTF-8.B.".base64_encode($subject).".=", $message, $headers ); .>
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.