0

I currently have a form that sends an email with some of the content from the form when a product is created. The trouble I'm having is getting the email content to look right as I can't figure out the styling of the string. Currently I have this setup..

$to = "email@email.com";
$subject = $id . " has been added to PMS";
$txt = "<h1>A Product has been added to PMS!</h1> \n<b>Details</b> \nPart Number: " . $id . "\nName: " . $name . "\nProduct Family: " . $family . "\nPRF: " . $PRF;
$headers = "From: email@email.com" . "\r\n" .
"CC: other@email.com";

mail($to,$subject,$txt,$headers);

I'd like to add a <h1> to the first part but it simply puts out "<h1>A Product has been added to PMS!</h1>" I'd also like to add tables etc but can't figure out how to put them in without it adding the tags instead.

j08691
  • 204,283
  • 31
  • 260
  • 272
Spence
  • 35
  • 8
  • You're sending plain text email. If you want to send HTML email, you have to send HTML email. I **strongly** recommend using a library like SwiftMailer for this. – ceejayoz Jul 21 '17 at 15:50

1 Answers1

1

you need to provide content-type in headers.

  // To send HTML mail, the Content-type header must be set
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: email@email.com';
$headers[] = 'Cc: other@email.com';

For more information check this link http://php.net/manual/en/function.mail.php

Ravinder Reddy
  • 3,869
  • 1
  • 13
  • 22