Can only send email to my own domain

I have a server that uses Plesk. I have set up a subdomain for testing and am trying to get a script to send an email to my yahoo account. The thing is it won’t, no errors, no logs. If I send it to my own domain the email goes through. Anyone with any ideas.

Here’s my code

$to      = '';
$subject = 'Email Test';
$email_message = 'This is to test sending an email';							
$headers = '' . "\\r\

if (mail($to, $subject, $email_message, $headers)) {
	echo 'sent';
} else {
	echo 'failed';

now if i change this

$to      = '';


$to      = '';

it works fine.

Could be Yahoo is filtering those emails so you never see them. Maybe your IP is on a blacklist or something. Try a completely different email address if you can. I don’t think this is a PHP issue at all. You might be able to have someone check the mail logs on your server just to see if it’s getting sent. If so, the problem is elsewhere.

Cheers Robert for the reply. Tried various other emails I have and no luck. Strange thing is that I can send an email from say outlook or from my phone no problem but just not through my script. This is what led me to believe that the email address wasn’t blocked, but I could be wrong. I’ll contact my server guys and ask them. It may be a setting that needs ticking. Here’s hoping.

Hmmm… seems I spoke too soon. Now I can’t send email from my phone to my yahoo account so I guess it’s a blocking issue. Will contact my server guys to ask why