php - detect if email is sent

后端 未结 7 1561
面向向阳花
面向向阳花 2020-12-09 18:49

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($emailReci         


        
7条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 19:04

    I'd like to add a bit more information in @Daya's answer and I want to do bit modification in his answer and that is following:

    If the email will send successfully then not an issue but if mail function has error then how could developer will get the error and for that he/she can use error_get_last() function for getting last error and the modification is following:

    if(!$mail) {
      print_r( 'Mailer error: ' . error_get_last());
    } else {
      echo 'Message has been sent.';
    }
    

提交回复
热议问题