HowTo: Sending Email From PHP

Discussion in 'HOWTO-Related Questions' started by toffie, Sep 3, 2007.

  1. toffie

    toffie New Member

    to begin with, great article!

    second, it says in the end of the article that the mail() function is
    not good to send several mails after each other as the function opens up
    and closes the smtp connection for every mail sent..

    how to fix this then?

    can you get around it just by using CC or BCC?
    or are there any other solutions?

    I'm not after spamming :p I'm after a good solution to be able to send
    newsletters from my own site..
     
  2. sjau

    sjau Local Meanie Moderator

    you can easily set multiple recipients:

    Code:
    $to = [email protected] , [email protected]';
    
     
  3. toffie

    toffie New Member

    but thats not what I asked for.. I know you can have several To, CC and BCC..

    but will that affect the smtp server in that way it can block the email sender?
     
  4. falko

    falko Super Moderator ISPConfig Developer

  5. chuckl

    chuckl New Member

    I think the caution is really about the fact that mail() is a very rudimentary implementation. Any error message is along the lines of 'Something went wrong somewhere, mail send failed', which is a nightmare if it happens in the middle of sending 200 emails.

    For that purpose you need something a bit more 'industrial', I'd recommend you look at Swiftmailer, written as a successor to phpMailer, it's extremely powerful and has every bell and whistle you could wish for - batch sends etc, it's actively developed and supported, and very easy to implement.

    http://www.swiftmailer.org/

    Disclaimer - I have absolutely no ties or association with the product, other than that I looked at many different solutions to replacing phpMailer, and this was the best I found, and I am using it for that purpose.
     

Share This Page