Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to do html e-mail, sending via php?

Tags:

html

php

email

I've never done html e-mail before, I've just set up php mail using http://www.postmarkapp.com

I was wondering how I would go about sending php mail as html?

Does anybody have any previews of a php page sending html e-mail I can look at to get the jist of how it works?

Currently I'm just putting text into a variable and sending it as a message, how is it done for html?

Regards

like image 229
Latox Avatar asked Dec 14 '25 21:12

Latox


1 Answers

Do you still want to use Postmark to send emails?

In Postmark, you set the TextBody property to the text version of your message, and the HtmlBody property to the html version of it. It is good practice to always include both. Depending on whether your user's email client supports HTML or not, the appropriate message form is rendered. Read more on this here.

Edit: Added an example. I generally like splitting my string into separate lines so that I can indent it nicely like a real HTML file. Of course, if you used templates, that would make it so much better.

$htmlBody = "
<html>
    <body>
        Thank you for using our app!<br />
        - Super Awesome App Team
    </body>
</html>
";
like image 167
RabidFire Avatar answered Dec 16 '25 11:12

RabidFire



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!