I am adding a contact form on my website, and I would like to send an autoreply email in html. I can send one with php in simple text, but no clue how to add html. Please help!
Here is my code so I can get their info: -
$FirstName = $_REQUEST['firstname'] ;
-
$lastname = $_REQUEST['lastname'] ;
-
$companyname = $_REQUEST['companyname'] ;
-
$title = $_REQUEST['title'] ;
-
$phone = $_REQUEST['phone'] ;
-
$phoneext = $_REQUEST['phoneext'] ;
-
$fax = $_REQUEST['fax'] ;
-
$email = $_REQUEST['email'] ;
-
$inquiry = $_REQUEST['inquiry'] ;
-
$subject = "Inquiry Request submitted";
-
$EmailBody = "This in an inquiry e-mail sent from Website\r\nInquiry Request has been submitted by $FirstName $lastname\n";
-
$EmailDetails = "Company Name: $companyname\n";
-
$EmailDetails = $EmailDetails."Title: " . $title . "\n" ;
-
$EmailDetails = $EmailDetails."Phone: " . $phone . "\n";
-
$EmailDetails = $EmailDetails."Phone Ext: " . $phoneext . "\n";
-
$EmailDetails = $EmailDetails."Fax: ".$fax."\n" ;
-
$EmailDetails = $EmailDetails."Email: " .$email . "\n";
-
$EmailDetails = $EmailDetails."Inquiry:\r\n ". $inquiry . "\n";
-
$message = "$EmailBody \n $EmailDetails";
-
mail( "rjo@mydomain.com", $subject, $message, "From: $FirstName $lastname <$email>" );
-
header( "Location: http://www.mydomain.com/thankyou.php" );
-
And then here is the auto-reply: -
$email = $HTTP_POST_VARS[email];
-
$mailto = "$email";
-
$mailsubj = "Thank you for your interest in LSO, Inc.";
-
$mailhead = 'From: No Reply <noreply@lso-inc.com>' . "\r\n";
-
reset ($HTTP_POST_VARS);
-
$mailbody = "Dear $FirstName $lastname,\r\nThank you for your interest. We will be sure to get back to you within 24 hours.\r\nFor a quicker response, please call us at 1 (800) MY-DOMAIN. \r\n \r\nHere is your original request:\r\n \r\n";
-
while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; }
-
if (!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); }
-
Where and how to include the html email I designed baffles me. Any help would be appreciated.
4 4506 @RJOent
As always, the PHP manual is a great place to start: php.net/mail. Don't worry, I sometimes forget to search the manual before asking here too.
Look in the fourth example, pay attention to this code -
-
// To send HTML mail, the Content-type header must be set
-
$headers = 'MIME-Version: 1.0' . "\r\n";
-
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
-
-
Let me know if that helps,
Dan
@dlite922
I had tried the information on that page before and it didn't work. I took a look at it this morning realized what I was doing wrong and voila!
Thanks Dan!
Can you share with us what you did so that others in your situation can benefit?
Thanks,
Dan
@dlite922
Hello Dave,
Sorry it took me a little while to come back and reply. I think I have the code to where I want it. And I would love to share it with others.
Here is how I retrieve my values from the contact form: -
$FirstName = $_REQUEST['firstname'] ;
-
$lastname = $_REQUEST['lastname'] ;
-
$companyname = $_REQUEST['companyname'] ;
-
$title = $_REQUEST['title'] ;
-
$phone = $_REQUEST['phone'] ;
-
$phoneext = $_REQUEST['phoneext'] ;
-
$fax = $_REQUEST['fax'] ;
-
$email = $_REQUEST['email'] ;
-
$inquiry = $_REQUEST['inquiry'] ;
-
And I forward the info to our sales team:
Then I send an auto-reply to the customer: -
$companyname = "MyCompany";
-
$companymail = "noreply@mydomain.com";
-
$bcc = "me_thedesigner@mydomain.com";
-
-
# -=-=-=- MIME BOUNDARY
-
$mime_boundary = "----rjoentertainment.com----".md5(time());
-
# -=-=-=- MAIL HEADERS
-
$mailhead = "From: $companyname <$companymail>\n";
-
$mailhead .= "BCC: RJOent <$bcc>\n";
-
$mailhead .= "MIME-Version: 1.0\n";
-
$mailhead .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"\n";
-
-
$mailto = "$email";
-
-
$mailbody = "--$mime_boundary\n";
-
$mailbody .= "Content-Type: text/html; charset=UTF-8\n";
-
$mailbody .= "Content-Transfer-Encoding: 8bit\n\n";
-
-
$mailbody .= "<html>";
-
$mailbody .= "<body leftmargin=\"0\" marginwidth=\"0\" topmargin=\"0\" marginheight=\"0\" offset=\"0\" bgcolor=\"#052c48\" >";
-
$mailbody .= "<table width=\"100%\" cellpadding=\"10\" cellspacing=\"0\" bgcolor=\"#052c48\" >";
-
$mailbody .= "<tr>";
-
$mailbody .= "<td valign=\"top\" align=\"center\">";
-
-
$mailbody .= "<table width=\"600\" cellpadding=\"0\" cellspacing=\"0\">";
-
$mailbody .= "<tr>";
-
$mailbody .= "<td style=\"background-color:#d6ebff;border-top:0px solid #000000;border-bottom:1px solid #FFFFFF;text-align:center;\" align=\"center\"><span style=\"font-size:10px;color:#996600;line-height:200%;font-family:verdana;text-decoration:none;\">Email not displaying correctly? <a href=\"http://www.rjoentertainment.com.com\" style=\"font-size:10px;color:#996600;line-height:200%;font-family:verdana;text-decoration:none;\">View it in your browser.</a></span></td>";
-
-
$mailbody .= "</tr>";
-
-
$mailbody .= "<tr>";
-
$mailbody .= "<td align=\"left\" valign=\"middle\" style=\"background-color:#FFFFFF;border-top:0px solid #333333;border-bottom:10px solid #FFFFFF;\"><center><a href=\"\"><IMG id=editableImg1 SRC=\"http://www.rjoentertainment.com.com/images/email/email_top_mpt.jpg\" BORDER=\"0\" width=\"600\" height=\"110\" title=\"LSO, Inc.\" alt=\"title1.\" align=\"center\"></a></center></td>";
-
$mailbody .= "</tr>";
-
-
-
$mailbody .= "</table>";
-
-
$mailbody .= "<table width=\"600\" cellpadding=\"20\" cellspacing=\"0\" bgcolor=\"#FFFFFF\">";
-
$mailbody .= "<tr>";
-
-
$mailbody .= "<td bgcolor=\"#FFFFFF\" valign=\"top\" width=\"400\" ALIGN=\"justify\" style=\"font-size:12px;color:#000000;line-height:150%;font-family:trebuchet ms;\">";
-
-
$mailbody .= "<p>";
-
$mailbody .= "<span style=\"font-size:20px;font-weight:bold;color:#052c48;font-family:arial;line-height:110%;\">Dear $FirstName $lastname,</span><br>";
-
-
$mailbody .= "Thank you for contacting RJOentertainment.com. We have received your request for information regarding our Package Testing / Validation services and we will respond within one (1) business day.";
-
$mailbody .= "<br><br>";
-
$mailbody .= "</p>";
-
$mailbody .= "<p>";
-
$mailbody .= "<span style=\"font-size:20px;font-weight:bold;color:#052c48;font-family:arial;line-height:110%;\">For a quicker response</span><br>";
-
$mailbody .= "please call us at (714) 555-1234 and ask for one of the representatives listed to the right of this message.</p> ";
-
$mailbody .= "<br>Thanks again for your inquiry,<br><br>";
-
$mailbody .= "<b>RJO<br>";
-
$mailbody .= "<b><i><font face=\"times new roman\">A division of</font></i><br>";
-
$mailbody .= "<b><i><font face=\"times new roman\" color=\"#0d2d84\">Life Science Outsourcing, Inc.</font></i></b>";
-
$mailbody .= "<br><br>";
-
//$mailbody .= "<b>rjoentertainment.com, Inc.</b><br>";
-
//$mailbody .= "1234 Main Street<br>";
-
//$mailbody .= "Townville, Ca 90000<br>";
-
//$mailbody .= "Tel ( 714) 555-1234<br>";
-
//$mailbody .= "Fax (714) 555-1235 <br>";
-
-
$mailbody .= "</p>";
-
-
$mailbody .= "</td>";
-
-
-
$mailbody .= "<td width=\"200\" valign=\"top\" style=\"background-color:#FFFFFF;border-left:1px dashed #CCCCCC;text-align:left;\">";
-
$mailbody .= "<span style=\"font-size:11px;font-weight:normal;color:#303d4a;font-family:arial;line-height:150%;\">";
-
-
$mailbody .= "<span style=\"font-size:15px;font-weight:bold;color:#333333;font-family:arial;line-height:150%;\">Person 1</span><br>";
-
$mailbody .= "Business Development Manager<br>";
-
$mailbody .= "<a href=\"mailto:email@rjoentertainment.com?subject=RE: Medical Package Testing\">email@rjoentertainment.com</a><br>";
-
$mailbody .= "(714) 555-1234<br>";
-
$mailbody .= "<a href=\"http://www.linkedin.com/in/rjosunai\"><img border=\"0\" src=\"http://static01.linkedin.com/img/logos/logo_82x23.png\" BORDER=\"0\" width=\"83\" height=\"23\" title=\"LinkedIn\" alt=\"LinkedIn\" align=\"center\"></a>";
-
-
$mailbody .= "<br><br><br><br><br><br>";
-
-
$mailbody .= "<span style=\"font-size:15px;font-weight:bold;color:#333333;font-family:arial;line-height:150%;\">Person 2</span><br>";
-
$mailbody .= "Business Development Manager<br>";
-
$mailbody .= "<a href=\"mailto:email@rjoentertainment.com?subject=RE: Medical Package Testing\">email@rjoentertainment.com</a><br>";
-
$mailbody .= "(714) 555-1234<br>";
-
$mailbody .= "<a href=\"http://www.linkedin.com/in/rjosunai\"><img border=\"0\" src=\"http://static01.linkedin.com/img/logos/logo_82x23.png\" BORDER=\"0\" width=\"83\" height=\"23\" title=\"LinkedIn\" alt=\"LinkedIn\" align=\"center\"></a>";
-
-
-
$mailbody .= "<br><br><br><br><br><br>";
-
-
$mailbody .= "<span style=\"font-size:15px;font-weight:bold;color:#333333;font-family:arial;line-height:150%;\">Person 3</span><br>";
-
$mailbody .= "Business Development Manager<br>";
-
$mailbody .= "<a href=\"mailto:email@rjoentertainment.com?subject=RE: Medical Package Testing\">email@rjoentertainment.com</a><br>";
-
$mailbody .= "(714) 555-1234<br>";
-
$mailbody .= "<a href=\"http://www.linkedin.com/in/rjosunai\"><img border=\"0\" src=\"http://static01.linkedin.com/img/logos/logo_82x23.png\" BORDER=\"0\" width=\"83\" height=\"23\" title=\"LinkedIn\" alt=\"LinkedIn\" align=\"center\"></a>";
-
$mailbody .= "</span>";
-
$mailbody .= "</td>";
-
$mailbody .= "</tr>";
-
$mailbody .= "<tr>";
-
$mailbody .= "<td style=\"background-color:#FFFFCC;border-top:10px solid #FFFFFF;\" valign=\"top\" colspan=\"2\">";
-
$mailbody .= "<span style=\"font-size:10px;color:#996600;line-height:100%;font-family:verdana;\">";
-
$mailbody .= "You are receiving this email because you indicated an interest in My Company. If you no";
-
$mailbody .= "longer wish to receive our emails, just send a quick note to us at unsubscribe@mydomain.com with";
-
$mailbody .= "UNSUBSCRIBE in the Subject line. <br />";
-
$mailbody .= "<br />";
-
$mailbody .= "</span>";
-
$mailbody .= "</td>";
-
$mailbody .= "</tr>";
-
$mailbody .= "</table>";
-
$mailbody .= "</td>";
-
$mailbody .= "</tr>";
-
$mailbody .= "</table>";
-
$mailbody .= "</body>";
-
$mailbody .= "</html>";
-
-
$mailsubj = "Thank you for your interest in Lorem Ipsum";
-
-
-
mail($mailto, $mailsubj, $mailbody, $mailhead );
-
I am still a newbie at php, so this might not be the best method. My goal, is to send our sales team the info provided in our info request form and the send the potential customer a nice looking email that basically says "Thanks, we'll be in touch soon."
So far this works. I hope someone benefits from this and if there is a better way, or you see an error in my code, please let me know!
Thanks Dave!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: philphanluvr |
last post by:
How do I sent content of a PHP form via HTML email?
For example, fields $name, $city, $state, $phone, $location
to HTML:
<p>Congratulations...
|
by: Ann |
last post by:
Hi,
I am trying to send a html email from a php script. This script emails
a common information to all the members in the database. The only...
|
by: D. Alvarado |
last post by:
Hello,
I have signed up a for a Google Gmail account. I sent myself some
PHP-generated HTML emails from two different machines using this code:
...
|
by: Brett |
last post by:
I have a client that wants to send HTML based email.
Building and sending isn't a problem, but he wants to include a plain text
link at the top...
|
by: akylitis |
last post by:
Hello All:
I am trying to understand how to set the ContentBase of an HTML email
I'm sending using CDO. The HTML source can be any .aspx page on...
|
by: patrice.fiset |
last post by:
Hi all,
When I send the html email, the only thing I receive is the tags (the
html codes basically). I want to be able to see the email like a...
|
by: mrajeshbabu |
last post by:
hi
this is Rajesh
i am working with email concept in asp.net 2.0
i am using html formatted email and
i have put in table control all the...
|
by: bthubbard |
last post by:
Hello All,
I am hoping to hear other people's suggestions and advice regarding
this issue.
Generating and sending a basic HTML email with...
|
by: lawpoop |
last post by:
Hello all --
I'm having a problem getting images to appear in the body of an HTML
email using PEAR's mail_mime class.
Here's my code, what am...
|
by: rahia307 |
last post by:
hi everybody
i want to send html email using php. please help me if any body have idea about it.
|
by: tammygombez |
last post by:
Hey fellow JavaFX developers,
I'm currently working on a project that involves using a ComboBox in JavaFX, and I've run into a bit of an issue....
|
by: tammygombez |
last post by:
Hey everyone!
I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
|
by: concettolabs |
last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
|
by: better678 |
last post by:
Question:
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?
Answer:
Java is an object-oriented...
|
by: CD Tom |
last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
|
by: CD Tom |
last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
| |