1

I am trying to use php mail() function on my new web server(linux based server) for my website. The issue is, emails are not sending to domain email addresses like some1@domain.com but its working fine for gmail, yahoo. I don't know what is the issue on it?. please give me suggestions or advice how to solve this issue. I want to send emails to domain-based email addresses.

my code is

//$to = $_POST['femail'];
$to = "<toadd@domain.com>";
$message = "

<html>
    <head>
        <title>".$subject."</title>
    </head>
    <body>
        <p>Registration request from site</p>
        <table>
            <tr>
                <td>Project Requested</td>
                <td>".$project."</td>
            </tr>
        </table>
    </body>
</html>";

// Always set content-type when sending HTML email

$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <info@domain.com>' . "\r\n";
$headers .= 'Cc: <some@domain.com>' . "\r\n";
$headers .= 'X-Mailer: PHP/' .PHP_VERSION. "\r\n";
@mail($to,$subject,$message,$headers);
SwiftArchitect
  • 47,376
  • 28
  • 140
  • 179

2 Answers2

1

I have faced the same issue..after a talk with hosting service provider I came to know that either sender or receiver's email id should be of the hosting domain id like if you have a site test.com either sender or receiver should have @test.com so you may do the same or talk to your hosting service provider.

lakshman
  • 656
  • 4
  • 18
0
$to = "toadd@domain.com"; //to address
$subject ="Your Subject";
$message = "Your message";
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: info@domain.com' . "\r\n"; //from address

if (mail($to, $subject, $message, $headers) )
{
    echo "Mail sent successfully";
}
else
{
    echo "failed to send mail";
}