SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: mail and mysql

  1. #1
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mail and mysql

    Ok, I have a table in my mysql db called "mail", there's only 1 field inside, "mail", before people download something, I ask them for their e-mail.
    I know how to select all the addresses from the db, but how do a send a mail to all the users?
    How can I implement all the addresses in the mail()?

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    How about using a while loop with the recipient in the mail function being $row[0]:

    while($row=mysql_fetch_row($sql_result))
    {
    mail($row[0], ......);
    }

  3. #3
    SitePoint Zealot New Oddity's Avatar
    Join Date
    Jun 2001
    Location
    Georgia
    Posts
    102
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $email mysql_fetch_array($result);

    foreach (
    $email as $address$mailTo .= $address;

    mail($mailTo"Subject""Email content"); 
    --Odd
    "We all live in a yellow subroutine."
    "Some call it insanity; I call it inspiration!"

  4. #4
    [Call me Bram] iBram007's Avatar
    Join Date
    Feb 2001
    Location
    Belgium
    Posts
    339
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works fine!

    thank you very much!

  5. #5
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi, it is my conviction that the first source to consult regarding php questions is
    (believe it or not) the manual (RTFM ).

    http://php.net/manual/en/function.mail.php
    Code:
    bool mail (string to, string subject, string message [, string additional_headers [, string additional_parameters]])
    Function mail takes a forth [optional] arguement being any additional headers you
    want to send. You can use this to send a BCC (blind carbon copy) header and list all
    the recipients on your email list here. Then for the "to" arguement, instead of making
    this a person on your mailing list make it one of your email addresses(or an alias - an address you don't mind being broadcast to your entire mailing list)
    such as "my-list@my-domain.com". Then you will only have to call the mail function
    once.

    Caveat Emptor: I've only read this in the manual and not tried it myself. So I'm
    guessing that something like this would do the trick
    PHP Code:
    $to 'my-list@my-domain.com';
    $subject 'Todays Menu';
    $message 'Lobster Thermidor a Crevette with a mornay sauce served in a ' .
               
    'Provencale manner with shallots and aubergines garnished with ' .
               
    'truffle pate, brandy and with a fried egg on top and spam.';
               
    $bcc 'sally@spam.com, [email]bruce@lovelyspam.com[/email], [email]veronica@wonderfulspam.com[/email]';
    $headers "bcc: $bcc \n";

    mail($to$subject$message$headers); 
    Last edited by freakysid; Jul 4, 2001 at 22:59.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •