4 replies
How to check whether the mail has been successfully send using mail function in php?
#php
  • Profile picture of the author newmoon
    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!
    {{ DiscussionBoard.errors[2167224].message }}
  • Profile picture of the author khay
    Bear in mind that mail() will return true if the function itself ran ok - regardless of whether the email was delivered or not.
    {{ DiscussionBoard.errors[2197276].message }}
  • Profile picture of the author blazenetworks
    Hi
    Syntax :
    mail(to,subject,message,headers,parameters)
    This is the best method used in php mail function.
    {{ DiscussionBoard.errors[2197900].message }}
  • Profile picture of the author LP_User
    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).
    {{ DiscussionBoard.errors[2199376].message }}

Trending Topics