# HTML in PHP autoresponse email

**URL:** <https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828>\
**Category:** programming\
**Created:** [March 21, 2006, 7:05pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828 "2006-03-21T19:05:52Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ajax\_45](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Ajax\_45](https://forum.kirupa.com/u/Ajax_45)\
**Post date:** [March 21, 2006, 7:05pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828/1 "2006-03-21T19:05:52Z")

</div>

Hi.  
I was wondering if there was a way to put html in the email that would be automatically sent upon form submission.  
Or if there was a way to send a preformatted rtf instead of a bland txt.

TIA.

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [March 21, 2006, 7:09pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828/2 "2006-03-21T19:09:14Z")

</div>

Should be just a matter of inserting the html tags in the strings you are using to format the e-mail and also a change to the mime type tags

---

<div class="post-metadata">

**Author:** ![Ajax\_45](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Ajax\_45](https://forum.kirupa.com/u/Ajax_45)\
**Post date:** [March 21, 2006, 7:19pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828/3 "2006-03-21T19:19:45Z")

</div>

> \<? $email\_contents =  
> "Name: $name

Email: $email

Daytime Phone: $dphone

Mailing Address:  
$maddr

Zip-Postal: $code

City: $city

State-Province: $region

Country: $country

Certificate Amount: $amount

Form submitted on: $form\_submit\_date

";  
$replyemail = “[http://www.dolphinencounters.com/thanks.htm](http://www.dolphinencounters.com/thanks.htm)”;

$formsend = mail (“$owner\_email”, “$subject”, “$email\_contents”, “From: $email  
Reply-to:$email”);  
mail (“$email”, “Thank You From Dolphin Encounters Ltd.”, “$replyemail”, “From: [www.DolphinEncounters.com](http://www.DolphinEncounters.com)”);  
print “$form\_submitted\_message”;  
}

?\>

as in that…

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [March 21, 2006, 7:25pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828/4 "2006-03-21T19:25:09Z")

</div>

> [@Ajax-45](#):
>
> as in that…

or even like this:

```php
<? 
$email_contents =
"<html>
<body>
Name: $name<br>
Email: $email<br>
Daytime Phone: $dphone<br>
Mailing Address: 
$maddr<br>

Zip-Postal: $code<br>
City: $city<br>
State-Province: $region<br>
Country: $country<br>
Certificate Amount: $amount<br>

Form submitted on: $form_submit_date<br><br></body></html>";
$replyemail = "http://www.dolphinencounters.com/thanks.htm";

$formsend = mail ("$owner_email", "$subject", "$email_contents", "From: $email
Reply-to:$email");
mail ("$email", "Thank You From Dolphin Encounters Ltd.", "$replyemail", "From: www.DolphinEncounters.com");
print "$form_submitted_message";
}

?>

```

---

<div class="post-metadata">

**Author:** ![skOOb](https://avatars.discourse-cdn.com/v4/letter/s/8dc957/32.png) [@skOOb](https://forum.kirupa.com/u/skOOb)\
**Post date:** [March 21, 2006, 7:35pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828/5 "2006-03-21T19:35:49Z")

</div>

Need to set the Content-Type in header.

```php

        $message = "<div style=\"width:90%; margin-left:1em; margin-right:1em; padding:-5px 5px 5px 5px; border:1px dashed #aaaaaa; background-color:#FDFDE6; font-size:12px; font-family:courier;\">You are a boob<br></div>";
    
    // To send HTML mail, the Content-type header must be set
    $headers = "From: MOMMY <mom@yours.com>
" . "MIME-Version: 1.0
" . "Content-type: text/html; charset=iso-8859-1";

    
    // SEND
    if(mail("youremail@email.com", "subject", $message, $headers)) { echo "

email sent
"; exit; }
    else { echo "mail did not send"; }

```

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [March 21, 2006, 7:38pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828/6 "2006-03-21T19:38:10Z")

</div>

> You are a boob

hahahahahhahahahahaha:D

---

<div class="post-metadata">

**Author:** ![Ajax\_45](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Ajax\_45](https://forum.kirupa.com/u/Ajax_45)\
**Post date:** [March 21, 2006, 7:45pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828/7 "2006-03-21T19:45:01Z")

</div>

hmm. this was a nice run but my ‘superiors’ were talking about another process… well at least they are now.  
Thanks though, to both, my PHP know-how has been tweaked C:-)

---

<div class="post-metadata">

**Author:** ![Ajax\_45](https://avatars.discourse-cdn.com/v4/letter/a/e495f1/32.png) [@Ajax\_45](https://forum.kirupa.com/u/Ajax_45)\
**Post date:** [March 21, 2006, 7:52pm UTC](https://forum.kirupa.com/t/html-in-php-autoresponse-email/182828/8 "2006-03-21T19:52:45Z")

</div>

Wait a minute, those fixes still only seem to apply to the info that i, client, would recieve. if you note in the

> $replyemail = “[http://www.dolphinencounters.com/thanks.htm](http://www.dolphinencounters.com/thanks.htm)”;  
> string im trying to apply the HTML or send an rtf to the form submitter.  
> I dunno if the fix skOOb did was the explanation, but id just rather it not be a plain txt readout in the auto-reply email…

hope that cleared the water.:nerd:
