Best way to do html email sending via php?

I didn’t write html-e-mail before, I just installed php email using http://www.postmarkapp.com

I was wondering how am I going to send php mail as html?

Does anyone have any previews of a php page sending an html email address that I can look at to understand how this works?

Currently, I just put the text in a variable and send it as a message, how is this done for html?

Hi

+3
source share
4 answers

Do you still want to use Postmark to send emails?

Postmark TextBody HtmlBody html-. . , HTML , . .

: . , , HTML . , , .

$htmlBody = "
<html>
    <body>
        Thank you for using our app!<br />
        - Super Awesome App Team
    </body>
</html>
";
+4

html , , , - text/html.

$headers.= 'MIME-Version: 1.0' . "\r\n";
$headers.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers.= "From: eaxfd@gmail.com \r\n";
$headers.= "Reply-To: eaxfd@gmail.com \r\n";
mail($to,$subject,$message,$headers);
+1

http://phpmailer.worxware.com/

This is the best class I have found for sending mail with PHP. It allows you to format HTML with an alternative part of plain text, as well as attachments. It also seems to filter out spam well enough when it is used for online forms.

+1
source

You just need to include the html headers in your function call mail():

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1';

mail($to, $subject, $message, $headers);
0
source

Source: https://habr.com/ru/post/1778122/


All Articles