0

How can i remove this line via p3nlhg946.shr.prod.phx3.secureserver.net in from address in the emails that are sent through the mail function in PHP. Thanks in advance.

<?php
 $to      = '[email protected]';
 $subject = 'Subject Line';
 $message = 'This is message';
 $headers = 'From: Admin<[email protected]>' . "\r\n" .
 'Reply-To: [email protected]' . "\r\n" ;
  mail($to, $subject, $message, $headers);
?>

I am receiving email like this

Admin [email protected] via p3nlhg723.shr.prod.phx3.secureserver.net

Srikanth Kolli
  • 892
  • 1
  • 8
  • 19

2 Answers2

0

You have to specify a FROM address, otherwise the default function of sendmail (not mail() itself) is to use [email protected] as the FROM

<?php
$to      = '[email protected]';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: [email protected]' . "\r\n";

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

http://php.net/manual/en/function.mail.php

Machavity
  • 30,841
  • 27
  • 92
  • 100
0

I assume that you are seeing this on gmail. If you are using the standard mail function without authenticating to your SMTP account, gmail would mark it as sent via the real server no matter which address you provide in the $to field.

You could try using the SMTP method instead: Send email using the GMail SMTP server from a PHP page

Community
  • 1
  • 1
gat
  • 2,872
  • 2
  • 18
  • 21