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      = 'usermail@mail.com';
 $subject = 'Subject Line';
 $message = 'This is message';
 $headers = 'From: Admin<webmaster@admin.com>' . "\r\n" .
 'Reply-To: webmaster@admin.com' . "\r\n" ;
  mail($to, $subject, $message, $headers);
?>

I am receiving email like this

Admin webmaster@admin.com 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 root@your.server.hostname as the FROM

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\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