Приветствую всех, решил организовать отправку письма о новом заказе с сайта на почту уполномоченному принимать данные письма, всё хорошо, письма отправляются, но вот стили нет, питаюсь оформить письмо красивым образом, в конечном итоге в письме выводиться вся html структура. Подскажите пожалуйста в чём моя ошибка, вроде всё делаю по инструкции. Вот html: HTML: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Logo</title> <style type="text/css"> html { -webkit-text-size-adjust: none; -ms-text-size-adjust: none; } @media only screen and (min-device-width: 660px) { .table660 { width: 660px !important; } } @media only screen and (max-device-width: 660px), only screen and (max-width: 660px) { .table660 { width: 100% !important; } .mob-radius-right { border-radius: 0 3px 3px 0; } .mob-radius-left { border-radius: 3px 0 0 3px; border-left: 1px solid #ebebeb !important; } } .table660 { width: 660px; } </style> </head> <body style="margin: 0; padding: 0;"> <span class="preheader" style="display: none !important; visibility: hidden; opacity: 0; color: #fff; height: 0; width: 0; font-size: 1px;">Прехедер</span> <table cellpadding="0" cellspacing="0" border="0" width="100%" style="font-size: 1px; line-height: normal;"> <tr> <td align="center" bgcolor="#ffffff" style="background-color: #ffffff;"> <!--[if (gte mso 9)|(IE)]> <table cellpadding="0" cellspacing="0" border="0" width="660"><tr><td> <![endif]--> <table cellpadding="0" cellspacing="0" width="100%" border="0" class="table660" style="max-width: 660px; min-width: 320px; width: 100%;"> <tr> <td align="center" valign="top"> <div style="height: 45px; line-height: 45px; font-size: 43px"> </div> <a href="" target="_blank"><img src="https://imgems.ru/ems/091219/logo.png" height="64" width="145" border="0" alt="" style="display: inline-block" /></a> <div style="height: 45px; line-height: 45px; font-size: 43px"> </div> <div style="height: 1px; line-height: 1px; font-size: 1px; border-top-width: 1px; border-top-style: solid; border-top-color: #e6e6e6"> </div> <table cellpadding="0" cellspacing="0" border="0" width="87.9%" align="center" style="margin: 0 auto; max-width: 87.9%; min-width: 87.9%;"> <tr> <td> <div style="height: 50px; line-height: 50px; font-size: 48px"> </div> <div align="center"> <span style="font-family: Arial, sans-serif; font-size: 28px; line-height: 38px; color: #191919;">Проверьте, актуальны ли ваши данные в анкете на VALAR MARGULIS.RU.</span> <div style="height: 20px; line-height: 20px; font-size: 18px"> </div> <span style="font-family: Arial, sans-serif; font-size: 20px; line-height: 30px; color: #999999;">Укажите полную информацию о себе и вам не придется заполнять поля при оформлении заказа каждый раз — ваши имя, адрес доставки подставятся автоматически.</span> </div> <div style="height: 35px; line-height: 35px; font-size: 33px"> </div> <div> <!--[if mso]> <v:rect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="http://" style="height: 68px; v-text-anchor: middle; width: 580px;" strokecolor="#303030" fillcolor="#303030"> <w:anchorlock/> <center style="color:#ffffff; font-family: Arial, sans-serif; font-size: 17px;">Открыть личный кабинет</center> </v:rect> <![endif]--> <a href="" style="background-color: #303030; color: #ffffff; display: inline-block; font-family: Arial, sans-serif; font-size: 17px; line-height: 70px; text-align: center; text-decoration: none; width: 100%; -webkit-text-size-adjust: none; mso-hide: all; background: #303030; border-radius: 4px;">Открыть личный кабинет</a> </div> <div style="height: 40px; line-height: 40px; font-size: 38px"> </div> <div style="height: 1px; line-height: 1px; font-size: 1px; border-top-width: 1px; border-top-style: dotted; border-top-color: #ececec"> </div> <div style="height: 15px; line-height: 15px; font-size: 13px"> </div> <span style="font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; color: #999999;">Хороших покупок,<br />ваш VALAR MARGULIS</span> <div style="height: 25px; line-height: 25px; font-size: 23px"> </div> <div style="height: 1px; line-height: 1px; font-size: 1px; border-top-width: 2px; border-top-style: solid; border-top-color: #e6e6e6"> </div> <div style="height: 45px; line-height: 45px; font-size: 43px"> </div> <table cellpadding="0" cellspacing="0" border="0" align="center" style="margin: 0 auto;"> <tr> <td width="27"> <a href="" target="_blank"><img src="https://imgems.ru/ems/templates/vk.png" width="27" height="19" border="0" alt="" style="display: block" /></a> </td> <td width="50"> </td> <td width="27"> <a href="" target="_blank"><img src="https://imgems.ru/ems/templates/ig.png" width="27" height="19" border="0" alt="" style="display: block" /></a> </td> <td width="50"> </td> <td width="27"> <a href="" target="_blank"><img src="https://imgems.ru/ems/templates/fb.png" width="27" height="19" border="0" alt="" style="display: block" /></a> </td> <td width="50"> </td> <td width="27"> <a href="" target="_blank"><img src="https://imgems.ru/ems/templates/ok.png" width="27" height="19" border="0" alt="" style="display: block" /></a> </td> </tr> </table> <div style="height: 35px; line-height: 35px; font-size: 33px"> </div> <div align="center"> <span style="font-family: Arial, sans-serif; font-size: 13px; line-height: 18px; color: #999999;">Вы получили данное письмо, так как подписались на рассылку <a href="" target="_blank" style="font-family: Arial, sans-serif; font-size: 13px; line-height: 18px; color: #999999; text-decoration: none;">emailsoldiers.ru</a>.</span> <div style="height: 5px; line-height: 5px; font-size: 3px"> </div> <a href="" target="_blank" style="font-family: Arial, sans-serif; font-size: 12px; line-height: 18px; color: #191919; text-decoration: none;">Отписаться от рассылки</a> <div style="height: 30px; line-height: 30px; font-size: 28px"> </div> <span style="font-family: Arial, sans-serif; font-size: 13px; line-height: 18px; color: #999999;">Разработано в <a href="" target="_blank" style="font-family: Arial, sans-serif; font-size: 13px; line-height: 18px; color: #191919; text-decoration: none;">Email Soldiers</a></span> </div> <div style="height: 45px; line-height: 45px; font-size: 43px"> </div> </td> </tr> </table> </td> </tr> </table> <!--[if (gte mso 9)|(IE)]> </td></tr></table> <![endif]--> </td> </tr> </table> </body> </html> А это PHP: Код (Text): //Присваиваю html код переменной $data = 'HTML код'; //Функция отправки письма mail("m***iosif@yandex.ru", "Тест", $data); Заранее Благодарю всех
Писал, не помогает, это я готовый шаблон скачал в надежде по нему разобраться и понять как верстать письма, но и он не сработал
И весь ввод кодируешь в HTML, а то какую-нибудь бяку могут подсунуть --- Добавлено --- Ну, Mля, какие media-запросы в письмах!
Прочёл и попробовал, не срабатывает и всё, может я рукожопый, просмотри пожалуйста php код, что я делаю не правильно? Код (Text): $to='maharadzeiosif@yandex.ru'; $subject='=?utf-8?B?'.base64_encode('Тест').'?='; $message=chunk_split(base64_encode(' <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <div style="display: block;width: 90vw;border-radius: 5px;border: #FF7A00 1px;height: 150px;font-family: Arial, Helvetica, sans-serif;"></div> </body> </html> ')); $headers='MIME-Version: 1.0'."\r\n". 'Content-Transfer-Encoding: base64'."\r\n". 'Content-Type: text/plain; charset=utf-8'; mail($to,$subject,$message,$headers);
Или слепой? Для форматирования текста письма можно разместить в нем нужные HTML-теги и указать в последнем заголовке text/html вместо text/plain.