Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP newbie 1

Status
Not open for further replies.

Wulfgen

Technical User
Dec 31, 2004
283
0
0
US
Hello,
this is my very first post here: so please forgive my ignorance.. and... my first attempts at PHP as well. I'm using a cobbled together (from different places) the below script....

However, the emails that are being sent are using the $name and I would rather have it use the "From: Contact Form" that way you would be able to see where the email originated from....

Does that make any sense?

also... [ this would be really nice - I've seen some preformatted replys arrive in email sometimes html emails and other tiimes just nicely formatted email messages. Is there a way to add that feature (or something like it - maybe html code) to this script, where the ( mail($email, ) is?

Code:
<?PHP
$to = "name@url.com";
$msg .= "This message has been sent from your Flash Form\n\n";
$msg .= "Name: $name\n";
$msg .= "Email: $email\n";
$msg .= "Website: $website\n";
$msg .= "Address 1: $address1\n";
$msg .= "Address 2: $address2\n";
$msg .= "City: $city\n";
$msg .= "State: $state\n";
$msg .= "Zip Code: $zip\n";
$msg .= "Country: $country\n";
$msg .= "Message: $comment\n"; 
mail($to, $name, $msg, "From: Contact Form\nReply-To: $email\n");
[COLOR=red]mail($email, "Thank you for contacting Us","We will return your mail shortly\n
************************************
This is not SPAM! - This note is
autogenerated by completing the
information fields in our
contact page - Thankyou again. 
************************************
", "From: <url>");[/color]
?>
 
You need the headers set:

$to = "tothisperson@thisplace.com";
$from = "Webmaster or Whatever <webmaster@mywebsite.com>";
$subject = "Contact From Website";
$my_headers = "From: " . $from;
mail($to, $subject, $msg, $my_headers);
 
So it looks like this:....?

<?PHP
$to = "tothisperson@thisplace.com";
$from = "Webmaster or Whatever <webmaster@mywebsite.com>";
$subject = "Contact From Website";
$msg .= "This message has been sent from your Flash Form\n\n";
$msg .= "Name: $name\n";
$msg .= "Email: $email\n";
$msg .= "Website: $website\n";
$msg .= "Address 1: $address1\n";
$msg .= "Address 2: $address2\n";
$msg .= "City: $city\n";
$msg .= "State: $state\n";
$msg .= "Zip Code: $zip\n";
$msg .= "Country: $country\n";
$msg .= "Message: $comment\n";
mail($to, $subject, $msg, $my_headers);
mail($email, "Thank you for contacting Us","We will return your mail shortly\n
************************************
This is not SPAM! - This note is
autogenerated by completing the
information fields in our
contact page - Thankyou again.
************************************
", "From: <url>");
?>
 
No, that's not right.
The last parameter of the mail command are additional headers. The FROM information is taken out of these additional headers, just like the reply-to.
Code:
mail($email, "Thank you for contacting Us","We will return your mail shortly\n
************************************
This is not SPAM! - This note is
autogenerated by completing the
information fields in our
contact page - Thankyou again.
************************************
", "From:"[COLOR=red].$from[/color]);
I also do not see anywhere that you actually set something to $my_headers.
 
Use single quotes when you can.
Code:
$headers = 'Webmaster <cada@dd.com>';
mail('email', 'subject', 'contents', 'From: ' . $headers);

Try to avoid things like:
$x = 'f';
$x .= 's';
$x .= 'y';

Its better just to use one line of statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top