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($emailaddress, $fromaddress, $emailsubject, $body)
-
{
-
$eol="\r\n";
-
$mime_boundary=md5(time());
-
-
# Common Headers
-
$headers .= 'From: Sending Love<'.$fromaddress.'>'.$eol;
-
$headers .= 'Reply-To: Sending Love<'.$fromaddress.'>'.$eol;
-
$headers .= 'Return-Path: Sending Love<'.$fromaddress.'>'.$eol; // these two to set reply address
-
$headers .= "Message-ID: <".$now." TheSystem[color=black]@[/color]".$_SERVER['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=\"".$mime_boundary."\"".$eol;
-
-
$msg = "";
-
-
# Setup for text OR html
-
$msg .= "Content-Type: text".$eol;
-
-
# Text Version
-
$msg .= "--".$mime_boundary.$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.$eol;
-
-
# HTML Version
-
$msg .= "--".$mime_boundary.$eol;
-
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
-
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
-
$msg .= $body.$eol.$eol;
-
-
# Finished
-
$msg .= "--".$mime_boundary."--".$eol.$eol; // finish with two eol's for better security. see Injection.
-
-
# SEND THE EMAIL
-
ini_set(sendmail_from,$fromaddress); // the INI lines are to force the From Address to be used !
-
mail($emailaddress, $emailsubject, $msg, $headers);
-
ini_restore(sendmail_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 = $body."This is a request for service from a customer <br>";
-
$body = $body."<b>Customer Name: </b>".$_REQUEST['cust_name']."<br>";
-
$body = $body."<b>Address: </b>".$_REQUEST['cust_address']."<br>";
-
$body = $body."<b>City: </b>".$_REQUEST['cust_city']."<br>";
-
$body = $body."<b>Province/State: </b>".$_REQUEST['cust_provstate']."<br>";
-
$body = $body."<b>Zip: </b>".$_REQUEST['cust_postzip']."<br>";
-
$body = $body."<b>Country: </b>".$_REQUEST['cust_country']."<br>";
-
$body = $body."<b>E-Mail: </b>".$_REQUEST['cust_email']."<br>";
-
$body = $body."<b>Customer is Intersted in: </b>".$_REQUEST['cust_interest']."<br>";
-
$body = $body."<b>Other Specification: </b>".$_REQUEST['cust_interest_other']."<br>";
-
$body = $body."<b>Design Selection: </b>".$_REQUEST['design_select']."<br>";
-
$body = $body."<b>Color Preferences: </b>".$_REQUEST['color_pref']."<br>";
-
$body = $body."<b>Customer Pertinent Info: </b>".$_REQUEST['cust_pertinfo']."<br>";
-
$body = $body."<b>Anything else the customer would like to see: </b>".$_REQUEST['cust_ideas']."<br>";
-
$body = $body."<b>Things 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>Quantity: </b>".$_REQUEST['quantity']."<br>";
-
$body = $body."<b>Can you use the finished product as a design example? : </b>".$_REQUEST['cust_permission']."<br>";
-
$body = $body."<b>How did you find us?: </b>".$_REQUEST['found_us']."<br>";
-
-
#Add all other parts here
-
#----------------------------------------------------------------
-
-
send_mail($emailaddress, $fromaddress, $emailsubject, $body);
-
?>
-
TIA for your Help!
4 1852
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; - # Text Version
-
$msg .= "--".$mime_boundary.$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.$eol;
-
-
# HTML Version
-
$msg .= "--".$mime_boundary.$eol;
-
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
-
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
-
$msg .= $body.$eol.$eol;
-
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.
Hi,
The error is occurring here; - # Text Version
-
$msg .= "--".$mime_boundary.$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.$eol;
-
-
# HTML Version
-
$msg .= "--".$mime_boundary.$eol;
-
$msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
-
$msg .= "Content-Transfer-Encoding: 8bit".$eol;
-
$msg .= $body.$eol.$eol;
-
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
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; -
function send_mail($emailaddress, $fromaddress, $emailsubject, $text_body = "", $html_body ="")//Just To make them optional.
-
{
-
# Text Version
-
$text_msg = "";
-
$text_msg .= "--".$mime_boundary.$eol;
-
$text_msg .= "Content-Type: text/plain; charset=iso-8859-1".$eol;
-
$text_msg .= "Content-Transfer-Encoding: 8bit".$eol;
-
$text_msg .= strip_tags(str_replace("<br>", "\n", $body)).$eol.$eol;
-
$text_msg .= $text_body.$eol.$eol;
-
-
# HTML Version
-
$html_msg = "";
-
$html_msg .= "--".$mime_boundary.$eol;
-
$html_msg .= "Content-Type: text/html; charset=iso-8859-1".$eol;
-
$html_msg .= "Content-Transfer-Encoding: 8bit".$eol;
-
$html_msg .= $html_body.$eol.$eol;
-
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!
:)
ak1dnar 1,584
Recognized Expert Top Contributor
Please do not post any email address with the code snippets. Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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.
|
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"
|
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
|
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))
| |
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;
|
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...
|
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...
|
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...
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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();...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |