I made a letter using HTML tags, such as <strong>
, <a>
, <h1>
well, etc. generally.
But the problem is that the letters come "as is", i.e. tags are processed as text. Sent from GMail, Yandex, and using a PHP script.
How to typeset letters?
Be sure to send an HTML header.
$headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type:text/html;charset=utf-8" . "\r\n"; $headers .= 'From: <from@example.com>' . "\r\n"; mail($to,$subject,$message,$headers);
All that is written is good, but far from the layout)
To typeset letters, you need to remember the layout of '95, and zayuzat everything that was in it.
Have a nice layout!
function send_mime_mail($name_from, // ΠΈΠΌΡ ΠΎΡΠΏΡΠ°Π²ΠΈΡΠ΅Π»Ρ $email_from, // email ΠΎΡΠΏΡΠ°Π²ΠΈΡΠ΅Π»Ρ $email_to, // email ΠΏΠΎΠ»ΡΡΠ°ΡΠ΅Π»Ρ $data_charset, // ΠΊΠΎΠ΄ΠΈΡΠΎΠ²ΠΊΠ° ΠΏΠ΅ΡΠ΅Π΄Π°Π½Π½ΡΡ
Π΄Π°Π½Π½ΡΡ
$send_charset, // ΠΊΠΎΠ΄ΠΈΡΠΎΠ²ΠΊΠ° ΠΏΠΈΡΡΠΌΠ° $subject, // ΡΠ΅ΠΌΠ° ΠΏΠΈΡΡΠΌΠ° $body // ΡΠ΅ΠΊΡΡ ΠΏΠΈΡΡΠΌΠ° ) { $to = $email_to; $subject = mime_header_encode($subject, $data_charset, $send_charset); $from = mime_header_encode($name_from, $data_charset, $send_charset).' <' . $email_from . '>'; if($data_charset != $send_charset) { $body = iconv($data_charset, $send_charset, $body); } $headers ="Content-type: text/html; charset=\"".$send_charset."\"\n"; $headers .="From: $from\n"; $headers.="Mime-Version: 1.0\n"; return mail($to, $subject, $body, $headers); } function mime_header_encode($str, $data_charset, $send_charset) { if($data_charset != $send_charset) { $str = iconv($data_charset, $send_charset, $str); } return '=?' . $send_charset . '?B?' . base64_encode($str) . '?='; }
Use phpmailer
from worx
there everything is simple: create an instance of the class, stuffed the data about the topic, the sender and the recipient, set the title and text of the letter and sent it.
Source: https://ru.stackoverflow.com/questions/139697/
All Articles