473,771 Members | 2,372 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Info from form shows in headers but not in body of email

2 New Member
I'm working on a PHP script, and the info from the form shows up in the headers of the email that I receive, but it doesn't show up in the body of the email. Can you please help me figure out what I'm doing wrong?

Here is the script:
Expand|Select|Wrap|Line Numbers
  1. <? function send_mail($emailaddress, $fromaddress, $emailsubject, $body)
  2. {
  3.   $eol="\r\n";
  4.   $mime_boundary=md5(time());
  5.  
  6.   # Common Headers
  7.   $headers .= 'From: Sending Love<'.$fromaddress.'>'.$eol;
  8.   $headers .= 'Reply-To: Sending Love<'.$fromaddress.'>'.$eol;
  9.   $headers .= 'Return-Path: Sending Love<'.$fromaddress.'>'.$eol;    // these two to set reply address
  10.   $headers .= "Message-ID: <".$now." TheSystem[color=black]@[/color]".$_SERVER['SERVER_NAME'].">".$eol;
  11.   $headers .= "X-Mailer: PHP v".phpversion().$eol;          // These two to help avoid spam-filters
  12.  
  13.   # Boundry for marking the split & Multitype Headers
  14.   $headers .= 'MIME-Version: 1.0'.$eol;
  15.   $headers .= "Content-Type: multipart/related; boundary=\"".$mime_boundary."\"".$eol;
  16.  
  17.   $msg = "";
  18.  
  19.   # Setup for text OR html
  20.   $msg .= "Content-Type: text".$eol;
  21.  
  22.   # Text Version
  23.   $msg .= "--".$mime_boundary.$eol;
  24.   $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  25.   $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  26.   $msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
  27.  
  28.   # HTML Version
  29.   $msg .= "--".$mime_boundary.$eol;
  30.   $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  31.   $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  32.   $msg .= $body.$eol.$eol;
  33.  
  34.   # Finished
  35.   $msg .= "--".$mime_boundary."--".$eol.$eol;  // finish with two eol's for better security. see Injection.
  36.  
  37.   # SEND THE EMAIL
  38.   ini_set(sendmail_from,$fromaddress);  // the INI lines are to force the From Address to be used !
  39.   mail($emailaddress, $emailsubject, $msg, $headers);
  40.   ini_restore(sendmail_from);
  41.   #echo "mail send";
  42. }
  43.  
  44.  
  45. # To Email Address
  46. $emailaddress="denise@REMOVED.net";
  47.  
  48. # From Email Address
  49. $fromaddress = "orders@REMOVED.ca";
  50.  
  51. # Message Subject
  52. $emailsubject="Web Customer Submission";
  53.  
  54.  
  55. #----------------------------------------------------------------
  56. # Message Body
  57. $body = $body."This is a request for service from a customer <br>";
  58. $body = $body."<b>Customer Name: </b>".$_REQUEST['cust_name']."<br>";
  59. $body = $body."<b>Address: </b>".$_REQUEST['cust_address']."<br>";
  60. $body = $body."<b>City: </b>".$_REQUEST['cust_city']."<br>";
  61. $body = $body."<b>Province/State: </b>".$_REQUEST['cust_provstate']."<br>";
  62. $body = $body."<b>Zip: </b>".$_REQUEST['cust_postzip']."<br>";
  63. $body = $body."<b>Country: </b>".$_REQUEST['cust_country']."<br>";
  64. $body = $body."<b>E-Mail: </b>".$_REQUEST['cust_email']."<br>";
  65. $body = $body."<b>Customer is Intersted in: </b>".$_REQUEST['cust_interest']."<br>";
  66. $body = $body."<b>Other Specification: </b>".$_REQUEST['cust_interest_other']."<br>";
  67. $body = $body."<b>Design Selection: </b>".$_REQUEST['design_select']."<br>";
  68. $body = $body."<b>Color Preferences: </b>".$_REQUEST['color_pref']."<br>";
  69. $body = $body."<b>Customer Pertinent Info: </b>".$_REQUEST['cust_pertinfo']."<br>";
  70. $body = $body."<b>Anything else the customer would like to see: </b>".$_REQUEST['cust_ideas']."<br>";
  71. $body = $body."<b>Things the customer doesn't want on their card: </b>".$_REQUEST['Cust_dont_want']."<br>";
  72. $body = $body."<b>Card Size: </b>".$_REQUEST['card_size']."<br>";
  73. $body = $body."<b>Card Finish: </b>".$_REQUEST['card_finish']."<br>";
  74. $body = $body."<b>Quantity: </b>".$_REQUEST['quantity']."<br>";
  75. $body = $body."<b>Can you use the finished product as a design example? : </b>".$_REQUEST['cust_permission']."<br>";
  76. $body = $body."<b>How did you find us?: </b>".$_REQUEST['found_us']."<br>";
  77.  
  78. #Add all other parts here
  79. #----------------------------------------------------------------
  80.  
  81. send_mail($emailaddress, $fromaddress, $emailsubject, $body);
  82. ?> 
  83.  
TIA for your Help!
Dec 20 '07 #1
4 1852
Ranjan kumar Barik
95 New Member
I'm working on a PHP script, and the info from the form shows up in the headers of the email that I receive, but it doesn't show up in the body of the email. Can you please help me figure out what I'm doing wrong?

Here is the script:
<? function send_mail($emai laddress, $fromaddress, $emailsubject, $body)
{
$eol="\r\n";
$mime_boundary= md5(time());

# Common Headers------------------headers not declared-------------
$headers .= 'From: Sending Love<'.$fromadd ress.'>'.$eol;
$headers .= 'Reply-To: Sending Love<'.$fromadd ress.'>'.$eol;
$headers .= 'Return-Path: Sending Love<'.$fromadd ress.'>'.$eol; // these two to set reply address
$headers .= "Message-ID: <".$now." TheSystem@".$_S ERVER['SERVER_NAME'].">".$eol;
$headers .= "X-Mailer: PHP v".phpversion() .$eol; // These two to help avoid spam-filters

# Boundry for marking the split & Multitype Headers
$headers .= 'MIME-Version: 1.0'.$eol;
$headers .= "Content-Type: multipart/related; boundary=\"".$m ime_boundary."\ "".$eol;

$msg = "";

# Setup for text OR html
$msg .= "Content-Type: text".$eol;

# Text Version
$msg .= "--".$mime_boundar y.$eol;
$msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
$msg .= strip_tags(str_ replace("<br>", "\n", $body)).$eol.$e ol;

# HTML Version
$msg .= "--".$mime_boundar y.$eol;
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
$msg .= $body.$eol.$eol ;

# Finished
$msg .= "--".$mime_boundar y."--".$eol.$eol ; // finish with two eol's for better security. see Injection.

# SEND THE EMAIL
ini_set(sendmai l_from,$fromadd ress); // the INI lines are to force the From Address to be used !
mail($emailaddr ess, $emailsubject, $msg, $headers);
ini_restore(sen dmail_from);
#echo "mail send";
}


# To Email Address
$emailaddress=" denise@REMOVED. net";

# From Email Address
$fromaddress = "orders@REMOVED .ca";

# Message Subject
$emailsubject=" Web Customer Submission";


#----------------------------------------------------------------
# Message Body-----------------------body not declared----------------------
$body = $body."This is a request for service from a customer <br>";
$body = $body."<b>Custo mer Name: </b>".$_REQUEST['cust_name']."<br>";
$body = $body."<b>Addre ss: </b>".$_REQUEST['cust_address']."<br>";
$body = $body."<b>City: </b>".$_REQUEST['cust_city']."<br>";
$body = $body."<b>Provi nce/State: </b>".$_REQUEST['cust_provstate ']."<br>";
$body = $body."<b>Zip: </b>".$_REQUEST['cust_postzip']."<br>";
$body = $body."<b>Count ry: </b>".$_REQUEST['cust_country']."<br>";
$body = $body."<b>E-Mail: </b>".$_REQUEST['cust_email']."<br>";
$body = $body."<b>Custo mer is Intersted in: </b>".$_REQUEST['cust_interest']."<br>";
$body = $body."<b>Other Specification: </b>".$_REQUEST['cust_interest_ other']."<br>";
$body = $body."<b>Desig n Selection: </b>".$_REQUEST['design_select']."<br>";
$body = $body."<b>Color Preferences: </b>".$_REQUEST['color_pref']."<br>";
$body = $body."<b>Custo mer Pertinent Info: </b>".$_REQUEST['cust_pertinfo']."<br>";
$body = $body."<b>Anyth ing else the customer would like to see: </b>".$_REQUEST['cust_ideas']."<br>";
$body = $body."<b>Thing s the customer doesn't want on their card: </b>".$_REQUEST['Cust_dont_want ']."<br>";
$body = $body."<b>Card Size: </b>".$_REQUEST['card_size']."<br>";
$body = $body."<b>Card Finish: </b>".$_REQUEST['card_finish']."<br>";
$body = $body."<b>Quant ity: </b>".$_REQUEST['quantity']."<br>";
$body = $body."<b>Can you use the finished product as a design example? : </b>".$_REQUEST['cust_permissio n']."<br>";
$body = $body."<b>How did you find us?: </b>".$_REQUEST['found_us']."<br>";

#Add all other parts here
#----------------------------------------------------------------

send_mail($emai laddress, $fromaddress, $emailsubject, $body);
?>

TIA for your Help!
Hi,
The error is occurring here;
Expand|Select|Wrap|Line Numbers
  1. # Text Version
  2.   $msg .= "--".$mime_boundary.$eol;
  3.   $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  4.   $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  5.   $msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
  6.  
  7.   # HTML Version
  8.   $msg .= "--".$mime_boundary.$eol;
  9.   $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  10.   $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  11.   $msg .= $body.$eol.$eol;
  12.  
The problem is, I think, you are making the same body into text version and again making it to html version. Use of html body for html versioning and plain body for text versioning will do a fever.

Two more errors in the coding.
Just check it in your original post, I have marked those.
Dec 21 '07 #2
sadieslc
2 New Member
Hi,
The error is occurring here;
Expand|Select|Wrap|Line Numbers
  1. # Text Version
  2.   $msg .= "--".$mime_boundary.$eol;
  3.   $msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  4.   $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  5.   $msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
  6.  
  7.   # HTML Version
  8.   $msg .= "--".$mime_boundary.$eol;
  9.   $msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  10.   $msg .= "Content-Transfer-Encoding: 8bit".$eol;
  11.   $msg .= $body.$eol.$eol;
  12.  
The problem is, I think, you are making the same body into text version and again making it to html version. Use of html body for html versioning and plain body for text versioning will do a fever.

Two more errors in the coding.
Just check it in your original post, I have marked those.
Ranjan,

Should I take out one or the other of the versions? Also, how do I declare the body and the headers?

Thanks,

Denise
Dec 21 '07 #3
Ranjan kumar Barik
95 New Member
Ranjan,

Should I take out one or the other of the versions? Also, how do I declare the body and the headers?

Thanks,

Denise
By removing the Html version, the mail function works well but,
you don't have to take out any one. You can declare two mail bodies like $text_body and $html_body and just pass two of them as parameters and make changes like this;
Expand|Select|Wrap|Line Numbers
  1. function send_mail($emailaddress, $fromaddress, $emailsubject, $text_body = "", $html_body ="")//Just To make them optional.
  2. {
  3. # Text Version
  4. $text_msg = "";
  5. $text_msg .= "--".$mime_boundary.$eol;
  6. $text_msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
  7. $text_msg .= "Content-Transfer-Encoding: 8bit".$eol;
  8. $text_msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
  9. $text_msg .= $text_body.$eol.$eol;
  10.  
  11. # HTML Version
  12. $html_msg = "";
  13. $html_msg  .= "--".$mime_boundary.$eol;
  14. $html_msg  .= "Content-Type: text/html; charset=iso-8859-1".$eol;
  15. $html_msg  .= "Content-Transfer-Encoding: 8bit".$eol;
  16. $html_msg .= $html_body.$eol.$eol;
  17.  
When calling the function you can pass any one "text" or "html", because they are optional. If you don't pass any of the two then a blank message will be sent.

I think it will work, just try.

Merry Christ mass!
:)
Dec 22 '07 #4
ak1dnar
1,584 Recognized Expert Top Contributor
Please do not post any email address with the code snippets. Thanks.
Dec 22 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2002
by: dave | last post by:
Hi, I know i shouldn't work on php forms when i'm going on 30 hours of no sleep, but i did anyway. I'm trying to get the below to work, and i keep getting a parse error line 74, an unexpected ',' there is none, so i'm assuming it's on another line, i've checked around, but don't see it. I'm probably missing something so simple that i'll call myself dumb for a month, but that's later, as of now i'd appreciate any help/suggestions. Thanks.
4
2739
by: Alberto | last post by:
I am struggling with the php mail function so to allow a multipart mime settings where both the message and any set of attachments can be allowed. Teorically, I'd know how to do. I build up my headers and pass them as the fourth argument of the function mail(). Practically, what happens is that whenever I try to test my script emailing myself, what appears in the email body are the __cleartext__ headers.
3
1738
by: Andy | last post by:
I need your help to check if my autoresponder will work in the following script. I am testing my PHP scripts on free server, which dosen't allow me to send email letters from my website. Please tell me if every thing is ok, if not please correct my mistake. Thank you for your help. This is: "contact_form.php"
8
12227
by: Du | last post by:
I'm trying to automate the upload process to yousendit.com, but the file size doesn't add up and yousendit.com keep rejecting my upload (it accepts the upload until the very end) I don't know what i'm missing, I use Fiddler and I got my header and body to a very close match, but the content-length is slightly off and I got no clue why Sorry for the lengthy post, but i have no other way of showing my work
2
6030
by: LD | last post by:
Hi, I am trying to upload a zip file and other form data elements to a server and get a response. The server keeps responding with Malformed Multipart Post. Can anyone see what might be wrong here? Any feedback much appreciated. Dim vbCrLf As String = Convert.ToString(Chr(13)) + Convert.ToString(Chr(10)) Dim vbCr As String = Convert.ToString(Chr(13)) Dim vbLf As String = Convert.ToString(Chr(10))
1
1445
by: cartoonsmart | last post by:
Hi I got the following script going; <?php $sendTo = "myemail@myemail.com"; $subject = "My web site reply"; $headers = "From: " . $_POST; $headers .= "<" . $_POST . ">\r\n"; $headers .= "Reply-To: " . $_POST . "\r\n"; $headers .= "Return-Path: " . $_POST;
4
5068
by: cybervigilante | last post by:
I sent HTML formatted email, using PHP, to my Yahoo address from my server, and it came out fine, styles and all. I sent it to my gmail address to test it and all I see is the raw html code. But I do get formatted email in gmail, so I know people make it work somehow. I'm looking right at a gmail message that I copied to Dreamweaver and it's using Strong and Red text attributes that work in gmail. But mine don't. What do you do...
2
1819
by: empiresolutions | last post by:
I am using a standard mail function within an AMFPHP Class that i have used many times. Now, when i use it it does not work right. When a mail is sent, the $header info and html shows in the email. I would like to know why the header info is showing in the email, along with why the HTML code is not rendering. I will post examples of code and result. Please provide a solution b4 i pull my hair out. Running PHP 4.3.9 on Apache function...
12
3841
by: colt28 | last post by:
Ok so I found an ajax contact form script but i can't get the b****** to work. I made a bunch of alterations to it and it didn't work so i replaced everything with the original and it still didn't work...dunno why, but anyhow. The form appears after a delay on the page in a hidden DIV. The original form just had name, email and message, but i have to add a few questions to it so i did and i also added some code from another script i found to...
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10260
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9910
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.