SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: php mail

  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    php mail

    Is there any way to detect if a message sent via the mail() function wasn't delivered? I have set a DB with bogus email accounts and using
    PHP Code:
     $send = @mail($ToName." <".$ToEmail.">",$ToSubject""$Message); 
    if (
    $send) { 
    echo 
    "- Mail sent successfully to " $email "<br>"
    } else { 
    echo 
    "- Mail sent <strong>UNSUCCESSFULLY</strong> to " $email "<br>"

    tested. All bad account on my server display the UNSUCCESSFUL message, all others display successful. If the message is 'sent' to a bad account, why wouldn't a 'Mail Delivery Subsystem [MAILER-DAEMON]: 550 unknown user' be sent to the From Address used to send the message? Is there any other way to determine bad email accounts? I have read the verifying email article, but that only verifies the domain name.

    Thanks
    NOEINK
    <Think Without Ink>

  2. #2
    public static void brain Gybbyl's Avatar
    Join Date
    Jun 2002
    Location
    Montana, USA
    Posts
    647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Usually if you send an email to an account that doesn't exist, the mailer daemon on that server will send a nice little message to the email address that the mail was sent from, nicely telling them that the email they were trying to access doesn't exist.

    This won't happen in all situations, ex// if there is no mailer-daemon on the server. Then, i'm not sure if there is any real way to 'trace' that email to it's destination.

    Another thing you might try is to request a read-receipt from the recipient, so you know that they got it... And if you didn't get one of these receipts within a certain amount of time, you would know that the email didn't exist...

    Just a suggestion.
    Ryan

  3. #3
    SitePoint Guru
    Join Date
    Aug 2001
    Location
    Amsterdam
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should add headers to the mail function and determine the from address.. this way the mailer deamon can send a mail back to you!!!!

    see some examples
    http://www.php.net/manual/en/function.mail.php

    greets,

    Peanuts
    the neigbours (free) WIFI makes it just a little more fun

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2002
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought I was using a From: in the header. Here is the code I am using: (some of info is pulled from db: $email, $first and $last_name and $code)
    PHP Code:
    //assign message variables
      
    $ToEmail $email;
      
    $ToName $first_name " " $last_name;
      
    $ToSubject "subject";
      
    $fromName "From Name";
      
    $fromEmail "[email=from@mydomain.com]from@mydomain.com[/email]";
      
      
    //add From: header 
      
    $content "From: " $fromName " <" $fromEmail ">\r\n"
      
      
    //specify MIME version 1.0 
      
    $content .= "MIME-Version: 1.0\r\n"
      
      
    //unique boundary 
      
    $boundary uniqid("HTMLDEMO"); 
      
      
    //tell e-mail client this e-mail contains//alternate versions 
      
    $content .= "Content-Type: multipart/alternative" 
         
    "; boundary = $boundary\r\n\r\n"
      
      
    //message to people with clients who don't 
      //understand MIME 
      
    $content .= "This is a MIME encoded message.\r\n\r\n"
      
      
    //plain text version of message 
      
    $content .= "--$boundary\r\n" 
         
    "Content-Type: text/plain; charset=ISO-8859-1\r\n" 
         
    "Content-Transfer-Encoding: base64\r\n\r\n"
      
    $content .= chunk_split(base64_encode("This is the plain text version!")); 
      
      
    //HTML version of message 
      
    $content .= "--$boundary\r\n" 
         
    "Content-Type: text/html; charset=ISO-8859-1\r\n" 
         
    "Content-Transfer-Encoding: base64\r\n\r\n";  
     
      
      
    //set header,footer, and encode with html code
      
    $message_header "this is the header\n\n\n";
      
    $footer "\n\n\nYou are subscribe as " $email;
      
    $temp $message_header $code $footer;
      
    $content .= chunk_split(base64_encode($temp)); 
      
      
    //send  message   
      
    $Message $content;  
         
      
    $send = @mail($ToName." <".$ToEmail.">",$ToSubject""$Message); 
      if (
    $send) { 
        echo 
    "- Mail sent successfully to " $email "<br>"
      } else { 
        echo 
    "- Mail sent <strong>UNSUCCESSFULLY</strong> to " $email "<br>"
      } 
    Any comments or suggestions freely welcomed.

    Thanks
    NOEINK
    <Think Without Ink>

  5. #5
    SitePoint Addict richard_h's Avatar
    Join Date
    May 2002
    Location
    London
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As Peanunts pointed out; you can add header information to deal with errors (bounced emails) -
    PHP Code:
     "Errors-To: <youremail@address.com>\r\n" 


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
  •