Don't send email to 'To' address

Help
danep
2009-08-14
2013-03-06
  • danep
    danep
    2009-08-14

    Hello- basically, I am wondering if it's possible to specify a "To" address but not actually send an email to that address (and instead send it somewhere else).

    I am trying to integrate PHPMailer with a Drupal module sometimes used for mailing lists. It seems that when you receive an email from most mailing lists, the "To" header lists the mailing list address (instead of your own address). This is the effect I'd like to mimic. I could do this by actually sending the mail to the mailing list address and BCCing recipients, but I'd prefer not to because this would require the mailing list to filter out messages that it sends to itself (not easy in my case because a completely different module receives such messages before they are eventually sent by mine). I know that this is definitely allowed for in the SMTP protocol (headers have nothing to do with the message envelope), I just don't know if it can be managed with PHPMailer.

     
  • lolfag
    lolfag
    2009-10-22

    This will help you, from the changelog...

    Version 2.0.0 rc2 (Fri, Nov 16 2007), interim release


    A note on sending bulk emails:

    If the email you are sending is not personalized, consider using the

    "undisclosed-recipient:;" strategy. That is, put all of your
    recipients

    in the Bcc field and set the To field to "undisclosed-recipients:;".

    It's a lot faster (only one send) and saves quite a bit on resources.

    Contrary to some opinions, this will not get you listed in spam engines -

    it's a legitimate way for you to send emails.

    A partial example for use with PHPMailer:

    $mail->AddAddress("undisclosed-recipients:;");

    $mail->AddBCC("email1@anydomain.com,email2@anyotherdomain.com,email3@a
    nyalternatedomain.com");

    Many email service providers restrict the number of emails that can be sent

    in any given time period. Often that is between 50 - 60 emails maximum

    per hour or per send session.

    If that's the case, then break up your Bcc lists into chunks that are one

    less than your limit, and put a pause in your script.


     
  • danep
    danep
    2009-10-22

    Thanks! That worked great in terms of getting the email sent - however, PHP
    exited with the error message "Invalid address: undisclosed-
    recipients:;". Any ideas?

     
  • danep
    danep
    2009-10-22

    Actually it seems to work fine if I simply comment out the AddAddress line.
    I'll assume that's the preferred solution? :)

     
  • Prince-W
    Prince-W
    2013-03-06

    Hi guys,

    I'm using phpmailer with:

    $mail->AddAddress("undisclosed-recipients:;");
    $mail->AddBCC(xxx); //to bunch of emails

    But the recipients receive email with blank "To" field without any indication of "undisclosed-recipients" where it should be listed there.

    Any idea? Or did I missed out something? Thank you.

     
  • Marcus Bointon
    Marcus Bointon
    2013-03-06

    Like the previous comment says, just omit the call to AddAddress and the 'undisclosed recipients' bit will happen automaticaly. Also please see the project page for the new home of PHPMailer.