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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mail subject confusion 1

Status
Not open for further replies.

g0ste

Technical User
Feb 16, 2003
95
AU
Hello,
I am having a problem with my mail script.

Basically I wish it to perform a simple mail function. I have it to send the recipient 4 text boxes and one drop down list selection.

My problem lies in the fact that when I test this email, the subject is fine (as it is hardcoded), however the sender says it is from "CGI-Mailer" with a reply to address of the host server (where ever that may be).

My code looks like this:

HTML form
Code:
<form action="send.php" method="post">
	<p>Name</p>
		<p><input type="text" name="name" maxlength="40"></p>
	<p>Phone</p>
		<p><input type="text" name="phone" maxlength="14"></p>
	<p>Email</p>
		<p><input type="text" name="email" maxlength="40"></p>
	<p>Type of site</p>
	<p><select name="type">
		<option value="No option selected">Please select an option...</option>
		<option value="Option one">Option 1</option>
		<option value="Option two">Option 2</option>
		<option value="Option three">Option 3</option>
		<option value="option 4 :D">option 4</option>
		<option value="option five">option 5</option>
	</select></p>
	<p>Additional Information</p>
		<textarea name="comments" rows="10" cols="40"></textarea>
	<input name="submit" type="submit" value="send">
</form>

and my PHP looks like this:
Code:
<?php
@extract($_POST);
//$from = "From: $name < $email >";
$sentby = "Quote / Enquiry requested by:\n$name < $email >\nPhone number: $phone\n\nType of site: $type";
mail('dan@mysite.co.uk','Website Enquiry',$comments,$sentby);
?>

When I receive a mail, the format is like this:

Subject reads "Website Enquiry" and the sender is "CGI-Mailer"

Everything else is formatted correct. I have tried moving parts around, but if I change the order of the to, subject and message, the whole layout of the received email goes wrong.

If anyone can shed any light on this, I would greatly appreciate it 8)

Thanks in advance!!

Dan
 
Well, thank you very much :)

I wasn't aware that you had to have a From: header! (it fixed it by the way!)

Well thanks again :)

You have saved me alot of hair :)

Dan
 
A "From:" header was set. As the PHP online manual entry for mail() states:

Note: When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in [tt]php.ini[/tt].

In your case, a default sender was set in your php.ini: CGI-Mailer. Your code now overrides the default.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top