SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jan 2008
    Location
    Palm Harbor, FL
    Posts
    348
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Verifying that an email was sent successfully

    I am creating a "Contact us" page with a form.
    Upon submission, a PHP script will send two emails:
    The first email is the support message, which is sent to us;
    the second is a confirmation email to the user.

    How could I program a PHP script to send these emails and verify that the emails were sent successfully?

    It is very important that the customer is notified if their message does not go through successfully.

  2. #2
    SitePoint Enthusiast derokorian's Avatar
    Join Date
    Jan 2011
    Location
    Ohio
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, the mail function returns true upon sending and false upon failure, so you could just throw it in an if statement like so:
    Code php:
    if ( mail( $to, $subject, $msg, $addheader ) ) {
         $content .= "<h1 class=\"home\">Feedback recieved.</h1>";
    } else {
         $content .= "<p class=\"error\">Message Failed to send!</p>";
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •