-1

Commented to2 variable is working fine. But Gmail id is not working. When I'm executing this code then first condition is printing Yes and second variable is printing No:

$to = "info@ebitmoney.com";
//$to2= "enquiry@ebitmoney.com";  //this variable is working
$to2= "abhisekh.milkyway@gmail.com"; // this is not working

$subject = "HTML email";

$message = "hello";

$header = "From: abhishek@milkywayservices.com\r\n"; 
$header.= "MIME-Version: 1.0\r\n"; 
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$header.= "X-Priority: 1\r\n";

$send1=mail($to,$subject,$message,$header);
$send=mail($to2,$subject,$message,$header);

if($send1){
    echo 'Yes';
}
else{
    echo 'No';
}

if($send){
    echo 'Yes';
}
else{
    echo 'No';
}
franiis
  • 1,378
  • 1
  • 18
  • 33
  • 1
    What is not working? Do you get any error messages? Or do you simply don't get any mails? I guess your sending mail server is not configured correctly and gmail rejects your mail because they are pretty strict. – Frieder Jul 05 '19 at 06:22
  • no i have not any error messages – Abhisekh Milkyway Jul 05 '19 at 06:24
  • This is not something you could fix with php.You should check with the email service on your server/pc.If linux then try `tail -f /var/log/mail.log` – Nuwan Attanayake Jul 05 '19 at 06:24

1 Answers1

0

Try this

//$to = "info@ebitmoney.com";
//$to2= "enquiry@ebitmoney.com";  //this variable is working
//$to2= "abhisekh.milkyway@gmail.com"; // this is not working
$email_to = "info@ebitmoney.com, abhisekh.milkyway@gmail.com";
$subject = "HTML email";

$message = "hello";

$header = "From: abhishek@milkywayservices.com\r\n"; 
$header.= "MIME-Version: 1.0\r\n"; 
$header.= "Content-Type: text/html; charset=ISO-8859-1\r\n"; 
$header.= "X-Priority: 1\r\n";

$send1=mail($email_to,$subject,$message,$header);
$send=mail($to2,$subject,$message,$header);

if($send1){
    echo 'Yes';
}
else{
    echo 'No';
}

if($send){
    echo 'Yes';
}
else{
    echo 'No';
}

If this doen't work, probably the problem is with your SMTP settings.
Please post your SMTP settings here. (Don't post the password..)

Lanka
  • 34
  • 8