Formatting PHP E-mail to be more presentable?

I have a form on my website that sends me an e-mail when filled out. This is the PHP i’m using currently;

<?php $name = $_POST['name']; $email = $_POST['email']; $date = $_POST['date']; $message = $_POST['message']; $from = 'From: Appointment Enquiry!'; $to = ''; $subject = 'Email Inquiry';
$body ="Name of Customer: $name\n Customer's E-Mail: $email\n Date for appointment: $date\n Message:\n $message";


<?php if ($_POST['submit']) { if (mail ($to, $subject, $body, $from)) { echo '

Thank you for your email!

'; } else { echo '

Oops! An error occurred. Try sending your message again.

'; } } ?>

How can I format the email I receive so it is more presentable? ie with an intro piece of text and bold headings?

read about HTML-Mails.

Also have a look at PHPMailer for sending emails - I read on here that the built-in mail() function is unreliable. I haven’t tried either myself, I should say.

I read that too. Perhaps it is but i have used the mail() function for years without (too many) problems. I used to send ~10k emails from our webserver using mail() for an enews system although this was 5 or so years ago.

I personally found it easy to use and still use it for various functions on our website.


That can get you into trouble with some hosts. I know of one ISP that disabled the mail() function for a user for sending as few (many) as 500 emails.

Agreed. We have a dedicated server and our host was fully aware of what we were doing. Shared servers etc probably not a good idea to do that unless your host knows about it.

But for 1 off type emails never had a problem with mail().

1 Like

I have used mail() for simple text emails where 100% success wasn’t a crucial requirement. And yes, my host had a batch send limit.

My being a newbie at the time was undoubtedly a factor, but I had a lot of trouble getting HTML emails to work with mail().

So if you want more than plain text emails where you don’t care if they may fail, then yes, take a look at something other than mail().

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.