php email form shows 'on behalf of' to outlook

Soldato
Joined
25 Jan 2007
Posts
4,738
Location
King's Lynn
I'm using a php based contact form on my site but it has an 'annoying' issue that I would like to fix...

The form works, it sends the message as required, all the validation etc works too but when I receive the message in outlook 2010 it shows
Server details on behalf of 'name of sender' <[email protected]> in the header.

Is there any way to remove the first bit (server details - not very secure) so all I have left is the name of sender and the email address. It doesn't have the issue in hotmail so it's clearly an outlook 'issue'.

I've read about an -f flag which might help but can't seem to find much about this.

Thanks in advance :)
 
Soldato
Joined
16 Jun 2013
Posts
5,375
No worries same place I was at php mail can be a real sod.


Is it pear mail.php plugin?


Can you show your code for calling/parsing to the mail.php? (Just remove password/email).
 
Last edited:
Soldato
OP
Joined
25 Jan 2007
Posts
4,738
Location
King's Lynn
You're right about php being a sod to learn, html/css (well what I need) is fairly easy but for some reason php just seems completely alien lol

Is it the pear mail.php plugin... not sure, pear is an option in cpanel but theres also apache, the server is linux based if that helps..

Code below, yeah not the most fancy and validation is 'currently' javascript, I'm not quite up to speed on php validation.... one baby step at a time lol
PHP:
<?php
$ip = $_SERVER['REMOTE_ADDR'];
$subject = "Message from Website";
$name = $_POST['name'] ;
$address = $_POST['address'] ;
$postcode = $_POST['postcode'] ;
$dayno = $_POST['dayno'] ;
$email = $_POST['email'] ;
$query = $_POST['query'] ;
$other = $_POST['other'] ;
$approxsize = $_POST['approxsize'] ;
$comments = $_POST['comments'] ;
 

$output = 
"Message from Contact Form \n\nSubmitted From: $ip \n\nQuery Type: $query \nOther: $other \n\nName: $name \nDaytime Number: $dayno \nEmail Address: $email \n\nAddress:\n $address  \nPostcode: $postcode \n\nComments:\n $comments \n\nApproximate Size: \n $approxsize " ;

$headers .= 'MIME-Version: 1.0' ;
$mailto = "email address"."\r\n";
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$headers .= 'Reply-To: $mailfrom' ."\r\n" ;
$headers = "From: $email"; 

mail ($mailto, $subject, $output, $headers);

header( "Location: /success.html" );
?>
 
Associate
Joined
10 Nov 2013
Posts
1,808
Is there any requirement for you to send the email using the from address of the person that filled in the form? From a quick google, the reason why you see the 'on behalf of' message is because the email server that is sending the email doesn't have the from address domain registered as a sending account. This is to help prevent people from spoofing emails from other accounts.

I assume all the emails that are being sent from this form are being sent to a central email address for you/someone to administer? If so there's no need for you to be spoofing the from address.
 
Associate
Joined
1 Jan 2013
Posts
178
Yes as above, try defining a reply address that is same as the domain being hosted. Something like this:

Code:
$returnaddress="[email protected]";
$headers = "From: <$returnaddress>\n";

Getting rid of your lines:

Code:
$mailfrom = isset($_POST['email']) ? $_POST['email'] : $mailto;
$headers .= 'Reply-To: $mailfrom' ."\r\n" ;
 
Soldato
OP
Joined
25 Jan 2007
Posts
4,738
Location
King's Lynn
Is the need for the email of the sender to be placed with the 'on behalf of'... not really, as long as I can still click 'reply' to reply to any emails without needing to fill in the email address I'm fine with that.
 
Associate
Joined
10 Nov 2013
Posts
1,808
I would have thought you'd want to do what jameshurrell suggested and set the from address to be something at your domain to avoid running into any issues. For each submitted form you can then set the reply-to address of the email to be the email address that was submitted through your form. That way all your posted emails will be presented to you with a single email address but when you reply to each one you'll be replying to the actual person's address.

Something like this...

Code:
$submittedAddress = $_POST['email'];
$returnaddress="[email protected]";

$headers = "From: <$returnaddress>\n";
$headers .= "Reply-To: <$submittedAddress>\n";
 
Back
Top Bottom