I have a mailer script I got from a website somewhere (I don't recall where exactly) that is successfully sending emails to a specific email account, the content of which is given from an HTML feedback form on my server.
if ($Debug != 0) echo '<pre>';
$Status = SendEmail($SmtpServer,25,$SmtpUserid,$SmtpPassword,
$To,$From,$From,$Subject,$Body,$Debug);
if ($Debug != 0) echo '</pre>';
if ($Status != '') {
if ($Debug == 0) echo '<html><body>' . "\n";
echo '<b>An error has occurred while sending the email.' . "\n";
echo 'The status message is:</b>' . "\n";
echo '<p>' . "\n";
echo htmlentities($Status,ENT_QUOTES) . "\n";
echo '</body></html>' . "\n";
exit;
}
if ($Debug == 0) header('location: ' . $NextPage);
?>
Now, my issue is that the emails that this script is sending has the content formatted something like this:
Quote:
Great websiteName = John
Body = Great website
Submit_x = 22
Submit_y = 4
Optimistically, I would like the emails to not have the "Name =","Body =","Submit =" etc., plus the message or body content repeats twice. Once at beginning and once after "Body ="...
I am not very knowledgeable in PHP scripting, so I am not sure what part of the script is formatting the emails, and what needs to be changed to remedy the situation...?
Thanks in advance for any help you guys can give me!!
- Michael
However, I need to make sure the "Name" string is in the body of the email message as well (The name is "John" in the example from my previous post).
For example, with the code you gave me, I just get an email that says "Great website" and nothing else.
What do I need to add in order to get it looking like "John, Great website" (this comes from the Name field in the form which has the same string name in the PHP script respectively) or "John," and then "Great website" on the next line ?
In other words, how do I get the input from the Name field and Body fields of the feedback form to both go into the message body of the email being sent?
- Michael
Last edited by moktoman; 06-29-2007 at 11:01 AM..
Reason: Clarification purposes
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
I just noticed the code I thought was duplicate code is actually checking both the POST and GET arrays so it's not duplicated, just flexible. Ooops...
Anyways, you can build the body of the email however you want it to look by using simple variable assignments. $Body is the name of the variable that ends up in the body of your email. The form input comes into the script via the $_POST or $_GET arrays, using the names of the form elements. So if you have a form element <input type="text" name="fuzzydice"> and submit the form with action="post", then the $_POST array will contain an index "fuzzydice": $_POST['fuzzydice'].
To "glue" strings together, use the period, like this: $Body = 'hi' . ' ' . 'there'; You can also imbed a variable within a string, like this (you must use double-quotes when imbedding): $Body = "You entered {$_POST['Name']} as the name.";