How to send email to multiple addresses using PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • syam
    New Member
    • Dec 2006
    • 28

    #1

    How to send email to multiple addresses using PHP

    Hai frnds..
    I have to send newsletters to multiple email ids which are stored in database. can i have to make a file containing all these id's from database or can i send to each of them taking from the database . please provide me a sample code...
  • ak1dnar
    Recognized Expert Top Contributor
    • Jan 2007
    • 1584

    #2
    Originally posted by syam
    Hai frnds..
    I have to send newsletters to multiple email ids which are stored in database. can i have to make a file containing all these id's from database or can i send to each of them taking from the database . please provide me a sample code...
    How many recipients for now.?
    Do you have those records already created in the database?

    Comment

    • syam
      New Member
      • Dec 2006
      • 28

      #3
      more than fifty recepients are there

      Comment

      • ak1dnar
        Recognized Expert Top Contributor
        • Jan 2007
        • 1584

        #4
        Originally posted by syam
        more than fifty recepients are there
        I think you have stored them in a table, right?

        you can use Php mail()
        So retrieve records (email address) from table and put it to the mail function.
        you do know how to use the Php with MySQL, do you?

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, Syam.

          TSDN members are expected to write their own code. We're happy to help you out if you have specific questions, but you can't realistically expect someone to do your coding for you on a free forum.

          Comment

          • gregerly
            Recognized Expert New Member
            • Sep 2006
            • 192

            #6
            Originally posted by pbmods
            Heya, Syam.

            TSDN members are expected to write their own code. We're happy to help you out if you have specific questions, but you can't realistically expect someone to do your coding for you on a free forum.
            I'll help out with the logic to get you started:

            [PHP]//select all email addresses
            $sql = "SELECT emailAddress FROM emailAddress_tb l;";
            $result=@mysql_ query($sql);

            //loop thru results and send the mail
            while(list($ema ilAddress)=@mys ql_fetch_row($r esult)){
            //set up the mail variables
            mail($emailAddr ess,$to,$messag e,$otherHeaders );
            }[/PHP]

            Hope that helps get you started.

            Greg

            Comment

            Working...