Hi, I've posted a similar thread a little while ago but to no avail.

I send out quite a large number of emails to my customers (not spam, it's to customers who have asked to be on my mailing list!) Now, at the moment all the emails are being bounced to root@mydomain.com, but I would like them to be bounced to a seperate address to make processing them easier. I cannot set the -f command when calling sendmail because I open a socket directly to it so I need to change the envelope/smtp from in the config somewhere.

I have tried hacking the .cf file and have so far managed to change the return path to the desired effect but this does not affect the bounces because the evelope from is still root@mydomain.com. When I run sendmail if -f, -vv & -d I get a whole load of bumf part of which calls the function setsender() which is not anywhere in the .cf file so I'm thinking this may need to be set elsewhere.

I'm not sure how much of the information I've given is necessary, if any. Any help would be greatly appreciated, I've been on this problem for about 4 days now. Even just directions to some good resources would be great. I've already checked out sendmail.org and comp.mail.sendmail.

Thanks Bubble

    6 days later

    This is the concluding chapter to my tumultuous adventures with Sendmail and a simple task. All I wanted to do (as can be seen from above) was to redirect bounced mails into a different folder. My journey began with this task at the sendmail.mc file. Looked simple enough, untill I tried to find the right directive for what I wanted to do. Then it started getting difficult. I originally thought that the destination of the bounce was dependent on the Return-path: header, which, in a way, it is. However changing this return path (a task which, for reasons which will be explained, require a rather messy hack on the .cf file) is not really advisable, in fact it's not really allowed, as according to RFC2821 the envelope header MUST be the same as the Return-path. Annoyingly Sendmail follows these standards and bounces to the envelope header regardless of the Return-path. Right new plan. Enter milter, moves to center stage and bawls out "YOU WILL NEED TO RE-COMPILE" and then moves off the stage again. I'm sitting on the floor with my hair in my hands when I head a soft voice behind my ear saying, "I can help you". Slowly I get up, drained of any enthusiasm or even hope and look in to the sweet gentle eyes of Procmail. She took me by the hand and gently guided me through the rest of my journey in lightning speed. We had our hicups but we were always moving forwards, and now I'm here. All my bounced emails are being diverted into /var/spool/mail/bounce and I'm starting to grow my hair back already. I'm happy 🙂

      5 months later

      Hi There,

      I'm surprised I missed this, always wondered where bounces whent -- untill I found that my var/mail/root file had grown to 379KB.

      suppose I execute:

      mail('thisisntspam@aol.com', 'sub','body','From: personsending@theirdomain.com');

      Did you find any way to get the mail sent back to "personsending@theirdomain.com"? I'd appreciate any assistance as my clients would learn when emails are then no good any more.

      Sincerely,
      Sam Fullman
      Compass Point Media

        If you're doing it on a mail-by-mail basis like you are it's quite a simple pocess; php's [man]mail()[/man] function allows you to add additional parameters as an optional, fifth argument. They even have an example of this very thing on the manual page

        Example 3. Sending mail with extra headers and setting an additional command line parameter.

        <?php
        mail("nobody@example.com", "the subject", $message,
             "From: webmaster@{$_SERVER['SERVER_NAME']}", "-fwebmaster@{$_SERVER['SERVER_NAME']}");
        ?> 

        Note: This fifth parameter was added in PHP 4.0.5. Since PHP 4.2.3 this parameter is disabled in safe_mode and the mail() function will expose a warning message and return FALSE if you're trying to use it.

        You can also use simple string building techniques to build complex email messages.

        HTH
        Bubble

          OK, I'll look into that, I just wasn't familiar with switches, however the problem is that a user is using a browser to send mail to someone. That user may be joe@aol.com, for example. The fourth parameter is going to need to be:

          "From: joe@aol.com"

          NOT

          "From: webmaster@myserverrootdomain.com"

          (BTW he's using my server to send really nice HTML postcards to friends). So that way, joe@aol.com gets the bounce so he knows that the mail he send was to a bad email. Did I not explain that or am I misunderstanding your answer? Thanks for elaborating.

          I appreciate your response, this is one of about 3 "holy grails" in programming I haven't found yet.

          Sam Fullman
          Los Angeles

            I don't get where you're confused, the -f switch makes the envelope from header into the email address after it, so if you've got this users email address in a variable then just put that variable after the -f switch.

              Absolutely great! Thank you, that will really improve efficiency for my users.

              By the way, I've got two other mail questions I won't be shy about asking:

              1. running the mail() command a couple hundred or even a thousand times is very slow, maybe 2-3 per second sent max; any way to speed this up? My understanding is that each time mail() is called a new socket is opened and closed (like I actually understand that), which is not very efficient, is there anyway to use the same socket each time?

              2. BCC's, yuck. I can't use BCC's when user's send out Mail Merge emails, but for emails without any data merging, I've tried to group all the emails into a BCC. However, it never works and I've honestly given up a few months ago. If you have a working example, I'd much appreciate.

              If I may ever be assistance with XML or esp. regular expressions (strong points), let me know.

              Sincerely,
              Sam Fullman
              Compass Point Media

                Originally posted by sfullman

                1. running the mail() command a couple hundred or even a thousand times is very slow, maybe 2-3 per second sent max; any way to speed this up? My understanding is that each time mail() is called a new socket is opened and closed (like I actually understand that), which is not very efficient, is there anyway to use the same socket each time?

                Unfortunately php is not very efficient when it comes to bulk emails. We built a multi-threaded java app to handle ours but I'm afraid I was not involved with it so I don't know how it works. For back-end, bulk emails I would deffinately suggest a slightly more heavy duty language and my personal choice would be Java.

                RE: your second point, I have not idea I'm afraid.

                Sorry
                Bubble

                  Originally posted by sfullman
                  2. BCC's, yuck. I can't use BCC's when user's send out Mail Merge emails, but for emails without any data merging, I've tried to group all the emails into a BCC. However, it never works and I've honestly given up a few months ago. If you have a working example, I'd much appreciate.

                  As a test, have you successfully used the To: or CC: field? I am not sure what the limit is, but if you are attempting to send to too many people at once, the BCC field may not be able to handle all your addresses. If that's the case, try breaking the list down to groups of 100 and sending out the mail in a loop.

                    Write a Reply...