-4

I am using free hosting of this link and i tried to user php send mail() but it does not work.. here is my code:

<?php
      if(mail('example@yahoo.com','from mail','your subscription is almost over, you need to renew', 'sample header')){
          echo 'mail sent';
      }else{echo 'not sent';}
?>

I tried also using this in localhost and edited my SMTP in php.ini. Is there any way in sending mail in php that will work also in free hosting?

pretty me
  • 509
  • 2
  • 5
  • 11

1 Answers1

0
// mail(to,subject,message,headers,parameters);
$to = 'example@yahoo.com';
$subject = 'Subscription Information';
$message = 'your subscription is almost over, you need to renew';
$headers = "From: info@mydomain.com" . "\r\n" .
            "CC: you_too@mydomain.com";

$mail =mail($to,$subject,$message, $headers);

if(isset($mail))
{
    echo 'mail sent';
}
else
{
    echo 'not sent';
}

image

PHP mail() Function

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85