Through a simple mail script, I can not send emails to addresses outside the domain (gmail, mail.com, outlook, etc.), while I can send emails only to the domain's email as support@domain.com.
through the php mail() function I can not send emails to email addresses belonging to other domains.
## not send email to Gmail accounts<?php
$to = 'alias@gmail.com';
$subject = 'test mail from domain.com';
$message = 'hello';
$headers = 'From: support@domain.com' . "\r\n" .
'Reply-To: support@domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
## work fine! send email to Domain.com accounts
<?php
$to = 'support@domain.com';
$subject = 'test mail from domain.com';
$message = 'hello';
$headers = 'From: support@domain.com' . "\r\n" .
'Reply-To: support@domain.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
I try to resolve with this solutions but not work: 1. modifiy .htaccess to define SMTP address (example: mail.domain.com) 2. config a DBconnet.php with ini_set('SMTP', "mail.domain.com"); 3. I have contact my hosting support but without a solution
How to resolve this problem? Have any idea?
Thanks