Log in

View Full Version : PHP form to email help



nate51
01-30-2009, 02:26 AM
I have everything working on a php form to email, the only issue is the emails are coming to me as CGI-Mailer [cgi-mailer@perfora.net]. Is their something I can drop into my php sending code to display something specific in the address? Like maybe the applicants email address or name or both?


-- nate

Nile
01-30-2009, 04:35 AM
Well, as I recall - cgi displays like this(first display, then code):


Name: Bob Frednik
<input type="text" name="Name" />


And someone typed Bob Frednik, so why don't you try:


<input type="text" name="Email" />


Change the highlighted as desired.

I hope this helps,
Nile

nate51
01-30-2009, 02:25 PM
I think there is some confusion here.

The html and php are working fine and displaying fine. When the emails come to me they are being sent to my junk box right away because they have the sender name and email address of "CGI-Mailer [cgi-mailer@perfora.net]" I want to assign a specific name to the emails or have the applicants email address displayed not the defualt name and email address of "CGI-Mailer [cgi-mailer@perfora.net]"

Schmoopy
01-30-2009, 06:19 PM
I think you are referring to the header within the mail function.

You can change the from to be anything you like. For example you could take the person's email:



$email = $_POST['email'];


and then add this to the header, which also specifies whether the email will be in HTML or text format.

The mail function is made up of 5 parameters, 2 of them being optional.

These are "to, subject, message, headers, parameters".

You only need the first 4 to get what you want.

So you can construct your message like this:



$to = "yourmail@mail.com";
$subject = "Subject here"; /* You could make this dynamic by allowing the user to enter it through an input box*/
$message = "Hello, this is my message";
$header = "From: Their Name <" . $email . ">";

// And then to send it

mail($to, $subject, $message, $header);


Hope this clears it up for you.

You can have any email address by changing the header really.

But it must always be in the format: "From: Jack <jack@mail.com>";

Good luck!