Dealing with Bounced Email

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Monty

    Dealing with Bounced Email

    I've written a simple e-newsletter app using the PHP mail() command.

    I want to be able to deal with bounce-backs if a member's email is no
    longer working or is using an old account. I'm using a Red Hat Linux
    server with Sendmail and Apache. I've seen mention of using Procmail or
    filtering mail to a certain account through a PHP script, but, can't
    find detailed instructions on how this is done.

    Can anyone let me know or point me toward a site that explains how to
    handle bounced-back email using Sendmail and a PHP script?

    Thanks!

  • windandwaves

    #2
    Re: Dealing with Bounced Email

    Monty wrote:[color=blue]
    > I've written a simple e-newsletter app using the PHP mail() command.[/color]
    [color=blue]
    > Can anyone let me know or point me toward a site that explains how to
    > handle bounced-back email using Sendmail and a PHP script?[/color]

    Try this:

    mail($To,$Subje ct,$Msg,$header s, '-f'.$returnaddre ss);


    where $returnaddress = your email.

    HTH

    - Nicolaas


    Comment

    • YeOldeSteve@gmail.com

      #3
      Re: Dealing with Bounced Email

      >"mail($To,$Sub ject,$Msg,$head er­s, '-f'.$returnaddre ss);[color=blue]
      >
      >where $returnaddress = your email. "[/color]

      this would not help as the action is not automated... try setting up
      an account that will be monitored by a script:
      On receving mail, remove sender's adress from database, also search
      body for e-mail adresses and remove them.

      Comment

      • windandwaves

        #4
        Re: Dealing with Bounced Email

        YeOldeSteve@gma il.com wrote:[color=blue][color=green]
        >> "mail($To,$Subj ect,$Msg,$heade r­s, '-f'.$returnaddre ss);
        >>
        >> where $returnaddress = your email. "[/color]
        >
        > this would not help as the action is not automated... try setting up
        > an account that will be monitored by a script:
        > On receving mail, remove sender's adress from database, also search
        > body for e-mail adresses and remove them.[/color]


        It sounds like you have a mailing list and you are trying to automate the
        remove response.

        It is easier to let people go to a specific page to remove.

        e.g.
        click on the link to remove


        then remove.php:

        <?

        if ( client_id_exist s($client) ) {
        if ( remove_client_f rom_database($c lient) ) {;
        echo "thank you for taking the time. your address has been removed";
        }
        }

        function remove_client_f rom_database {
        runsql
        }

        etc....
        ?>


        Comment

        • Monty

          #5
          Re: Dealing with Bounced Email

          YeOldeSteve@gma il.com wrote:[color=blue][color=green]
          > >"mail($To,$Sub ject,$Msg,$head er­s, '-f'.$returnaddre ss);
          > >
          > >where $returnaddress = your email. "[/color]
          >
          > this would not help as the action is not automated... try setting up
          > an account that will be monitored by a script:
          > On receving mail, remove sender's adress from database, also search
          > body for e-mail adresses and remove them.[/color]

          Okay, but, how does one set up a PHP script to monitor bounced email
          coming back to the account I've already set up? That's the part I have
          no idea how to do.

          Comment

          • Monty

            #6
            Re: Dealing with Bounced Email

            windandwaves wrote:[color=blue]
            >
            > It sounds like you have a mailing list and you are trying to automate the
            > remove response.[/color]

            No, what I want to do is deal with the bounce-backs after sending a
            broadcast email -- email that is returned because the email address is
            no longer active or valid. I want to set up a PHP script to
            automatically detect the returned email message, grab the email address
            from the bounced back email, then remove that email from the database.

            Specifically, I'm not sure how to go about using a PHP script with
            Sendmail to lift the TO: email address from a bounced back email when
            it is returned to the email account i have set up as the Return Path.

            Comment

            • Gordon Burditt

              #7
              Re: Dealing with Bounced Email

              >> >"mail($To,$Sub ject,$Msg,$head er­s, '-f'.$returnaddre ss);[color=blue][color=green][color=darkred]
              >> >
              >> >where $returnaddress = your email. "[/color]
              >>
              >> this would not help as the action is not automated... try setting up
              >> an account that will be monitored by a script:
              >> On receving mail, remove sender's adress from database, also search
              >> body for e-mail adresses and remove them.[/color]
              >
              >Okay, but, how does one set up a PHP script to monitor bounced email
              >coming back to the account I've already set up? That's the part I have
              >no idea how to do.
              >[/color]

              There are several approaches:

              (1) If you have a system which supports it (e.g. Linux or UNIX using
              sendmail, smail, Exim, etc.), you can forward mail received by a
              user into a pipe by specifying this in a .forward file in the user's
              home directory. The program (which could be written in just about
              anything: standalone PHP, Perl, sh, C, or whatever) will be invoked
              with the email text (including the headers) on stdin. Details of
              what user the program will run as or what the current working
              directory will be may vary. Whether or not the admin has turned
              this off or not may vary also. It is up to the program to go
              through the headers and body to figure out what to do with it.

              (2) You could set up a cron job which periodically invokes a program
              which polls a mailbox using POP3, IMAP, or just opens the mailbox
              file directly. For example, fetchmail can be used to transfer the
              mailbox contents to a local file. Then a program could look at
              what came in. The host with the program doesn't have to be the same
              host as the one with the mailbox, in the case of POP3 or IMAP polling.

              Gordon L. Burditt

              Comment

              • Tim Van Wassenhove

                #8
                Re: Dealing with Bounced Email

                On 2005-07-22, Monty <monty3@hotmail .com> wrote:[color=blue]
                > Specifically, I'm not sure how to go about using a PHP script with
                > Sendmail to lift the TO: email address from a bounced back email when
                > it is returned to the email account i have set up as the Return Path.[/color]

                man procmail


                --
                Met vriendelijke groeten,
                Tim Van Wassenhove <http://timvw.madoka.be >

                Comment

                Working...