Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6123377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:00:35+00:00 2026-05-23T16:00:35+00:00

Hi there I’m trying to send an HTML email through a PHP webform. The

  • 0

Hi there I’m trying to send an HTML email through a PHP webform. The form works fine and if I pass the variables such as $name, $address in to the message it goes through ok, but when I try to format it using HTML I can’t seem to get those variables passed into the message. This is an example code I found on w3schools but I can’t seem to adjust it to do what I want:

<?php
....
$to = "somebody@example.com, somebodyelse@example.com";
$subject = "HTML email";

$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
 ....
?>

What I’m trying to do is pass the variable $name where it says “john doe”, and I guess once I figure that out I should be able to pass through all my other variables as well.

Thanks in advance for all your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:00:35+00:00Added an answer on May 23, 2026 at 4:00 pm

    In order to get your variables into the message, if you are using double quotes, you should just be able to include the variable in the string:

    eg

    $message = "
    <html>
    ...
    <tr>
    <td>$name</td>
    </tr>
    ...
    </html>
    ";
    

    You can also break out of the string

    $message = "
    <html>
    ...
    <tr>
    <td>".$name."</td>
    </tr>
    ...
    </html>
    ";
    

    Which will work with single or double quotes (personally I prefer this method with single quotes).

    However when you receive this email, you will see the raw html. In order to have the html displayed properly you will need to set the appropriate mail headers. There are examples of how to do this here and here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a very useful Clips feature in Coda, does Eclipse have such feature?
There is a file as data.html. How to display the contents of this file
There are a TextField , a ListBox and a TextArea inside my Form .
there's a drop down html element for date for the current month (January 1
There is an application written in PHP which I am converting to Ruby. When
There are many tutorials that talk about deleting index.php from the url. But I
I am trying to loop through a bunch of documents I have to put
There is a shared folder in my D drive as works ( D:\works ).
There is a div (form) which opens on the click of a button. There
There is a conversion process that is needed when migrating Visual Studio 2005 web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.