$mailHeader Problem


I have a form currently working.

The client has asked me if i could change how he was receiving the inquires so that his email program would show the email of the person inquiring instead of showing his server information.

Example of what its currently doing:

I thought that by adding this simple line of php it would sort it out:

$mailHeader = "From: $urmail\

urmail is the field for the email.

This however did not work, instead i receive no message at all when i tried testing the form.

Ive also tried added \r
which also didn’t seem to work

Please see my full php snippet here

Would be grateful if this could be solved!
If html is needed let me know.

Are you remembering to transfer the email address from the $_POST[‘urmail’] field into $urmail

I beleive so…

This is a html snipper for the email section:

<td >
<div align="center" class="<?php if($errors_switch[1]) echo 'errorinput'; else echo 'fieldArea'; ?>">
<input type="text" name="urmail" id="urmail" value="<?php if(isset($_POST['urmail'])) echo $_POST['urmail'];?>" size="10"  class="inputNew2" style="font-family: Arial, Helvetica, sans-serif;font-size: 11px;color: #727986; border:none;width:123px; margin-top:1px; border-width:0; "/>


You need to fetch the urmail field from the form so you can use it in your code, like felgall pointed out.
The code you linked to does not do that until later in the code. It needs to happen before you use it.

$urmail = $_REQUEST['urmail'];
$mailHeader = "From: $urmail\\r\

You may want to validate the email before using it, though. Something like this will work with most emails:

if(preg_match('/^([\\w\\d.\\-_]+?)@([\\w\\d.\\-_]+?)\\.(\\w{2,4})$/i', $urmail)) {
    // Valid email
else {
    // Invalid email

Ive also tried added \r
which also didn’t seem to work

You should use \r
between headers, as per the standard. (According to the PHP manual.)

Thanks for your reply!

I tried doing this but had to luck, the form did not work at all.

Did you look at the snippet i posted at youshare?

Link Here

That contains the internal php code im using.

Yea, I looked over your code. There isn’t anything essentially wrong with it, but there seems to be something missing from it. Did you only post a part of it?

What exactly does the form do now?

I posted all of the php information and php effecting the html…
Read my first post to see what the form does.
when i add your code in it nothing happens.

Try moving the header lines down, until they’re just before where the mail message is created.

If that still fails, post an updated version of the code.

Hey guys,

Atil’s method actually worked
but it came through to my spam folder!