PHP

by 4 replies
5
How to check whether the mail has been successfully send using mail function in php?
#programming #php
  • PHP Code:
    if(mail(TO,SUBJECT,BODY,HEADERS)){
    //show success messages
    } else {
    //show failure messages

    That means the function returns Boolean (True/False) after sending mail. If it succeeds, it returns TRUE otherwise FALSE.

    Hope that helps!
  • Bear in mind that mail() will return true if the function itself ran ok - regardless of whether the email was delivered or not.
  • Hi
    This is the best method used in php mail function.
  • As above, the mail() function will only tell you if PHP was succesful in passing the mail out to the mail service on the server. Any faults at that end (or undeliverable) need to be handled elsewhere unless you fancy integrating php with the mailbox or mailer service on the server (not worth the time).
  • Banned
    [DELETED]
  • Banned
    [DELETED]
  • Banned
    [DELETED]

Next Topics on Trending Feed

  • 5

    How to check whether the mail has been successfully send using mail function in php?