Skip to content
Advertisement

php – detect if email is sent

Im building an automated newsletter, im kinda stuck with this problem. I need to know if the email was sent or not. Here is my code

 @$send = mail($emailRecipient, $subject, $message, $headers);

i tried to add it to an if statement but it does not work here is the code.

if( @$send = mail($emailRecipient, $subject, $message, $headers)){
   //do something
}else{
  //do something
}

Advertisement

Answer

if(@mail($emailRecipient, $subject, $message, $headers))
{
  echo "Mail Sent Successfully";
}else{
  echo "Mail Not Sent";
}
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement