SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    a forme sending to 2 email addresses?

    i use the following code:
    PHP Code:
        mail("lance_evans12@hotmail.com","Challenge from clan",
    $msg);
      echo 
    "Your challenge has been sent to venom, he will be in contact within 24 hours with further details.<br>\n";
      echo 
    nl2br($msg) . "<br>\n"
    just wanted to know if there is a reliable way so it sends the form reults to another email aswell.

  2. #2
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    one way:

    PHP Code:
    mail("lance_evans12@hotmail.com","Challenge from clan",
    $msg);

    mail("tripleplay01@hotmail.com","Challenge from clan",
    $msg); 
    I'm sure there is some true way of doing it, but that's how I do it. It works, but not the genious way of doing it!

  3. #3
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, sorry, just thought of something else:

    PHP Code:
    $sql mysql_query("SELECT * FROM user WHERE send='yes'");
    while(
    $row mysql_fetch_array($sql))
    {
    mail("$row['email']","Challenge from clan",
    $msg);

    If it's from a user table, for something like sending to all people who want a letter or somerhing.

    THe other way works for 2, but a loop is better for more than 2 people.

    Thanks,
    ~someonewhois

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2002
    Location
    shropshire, west midlands, UK
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    its ok

    the first one will suffice, i only need it to be sent to 2 fixed emails. Thanx for the speedy reply, i knew it was simple, just didnt want to mess it up :P.

  5. #5
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    mail("lance_evans12@hotmail.com, tripleplay01@hotmail.com","Challenge from clan",
    $msg);

  6. #6
    SitePoint Wizard silver trophy someonewhois's Avatar
    Join Date
    Jan 2002
    Location
    Canada
    Posts
    6,364
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I thought of that, but didn't think it would work.

    I guess that's the same as real e-mails, you can put commas in there.

    Note Venom: I suggest my way. Jofa's way is much more practical, however then your e-mail, shows up at mine, and now I knwo your e-mail.

    Some people want their e-mail private.

    In that case, mine, which is kind of a space taker uper p) since it's 2 functions, works better.

    It depends if you are only using your e-mail as admin, in that case then it doesn't matter, however if you're using 2 members names, then you'd want to keep the seperate unless they already can see it in a memberlist.

    Thanks,
    ~someonewhois

  7. #7
    SitePoint Enthusiast menkes's Avatar
    Join Date
    Jul 2002
    Location
    Channel Islands
    Posts
    75
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For reusability (like when you need more than 2 email addresses) try this:

    PHP Code:
    $header "BCC: ";
    $comma "";

    $sql mysql_query("SELECT * FROM user WHERE send='yes'");
    while(
    $row mysql_fetch_array($sql))
    {
      
    $header .= $comma $row['email'];
      
    $comma ", "
    }

    $header rtrim($header,", ");

    mail("Clan Members","Challenge from clan",
    $msg,$header); 
    This way you call the mail function only once, send a blind copy to all recipients so they cannot see another's address, and use a bogus (yet meaningful) address in the To: field ("Clan Members" in this example).

    You can even change the From field to "Clan Guru" by doing this:
    PHP Code:
    CHANGE:   $header rtrim($header,", ");
    TO:       $header rtrim($header,", ") . "\nFrom: Clan Guru"
    >>>>>>
    enjoy


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
  •