Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: multiple recipients mailform

  1. #11
    Join Date
    May 2007
    Location
    Sweden
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Here is what I mean, Chechu!

    Sendmail.php
    PHP Code:
    <?php 

    $defaultVal
    [0] = "Fill your name here";
    $defaultVal[1] = "Fill your name here";

        if( 
    $_POST["action"] == "send" 
        { 

        
    $send true;

        
    $name        $_POST['name']; 
        
    $email        $_POST['email']; 
        
    $message    $_POST['message']; 

            
    // Is name < 0 chars?
            
    if( strlen($name) < )
            {
            
    $error[] = "Please fill in your name";
            }

            
    // Is email in correct format?
            
    if( !ereg("[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+"$email ) )
            {
            
    $error[] = "Please insert correct email";
            }

            
    // Is message < 5 chars?
            
    if( strlen($message) < )
            {
            
    $error[] = "Please fill in your name";
            }

            
    // Number of errors!
            
    $num_of_error count($error);

            
    // Is there any errors? No, good send it!
            
    if( $num_of_error == )
            {

                 include(
    "messenger.lib"); 

                 
    $messenger = new messenger(); 

                
    // Set this to your own name and email-address ... 
                
    $messenger->setFrom("info@cecicasariego.com""Admin"); 

                
    $messenger->setBCC("jurgen.schepers@euphonynet.be""Jurgen"); 
                
    $messenger->setBCC("info@cecicasariego.com""Admin"); 

                
    // Set priority: 1 = High, 3 = Normal, 5 = Low 
                
    $messenger->setPrio(1); 

                
    // Set the subject ... 
                
    $messenger->setSubject("Je bericht aan hetbestevoordeel.be"); 


                
    // The user information 
                
    $messenger->setUserInfo( array( 

                    
    "NAME"        => $name
                    
    "MESSAGE"    => $message
                    
    "DATE"        => date("M d, Y H:i.s"time()) 
                    ) ); 

                
    // To who is it? 
                
    $messenger->setTo($email$name); 

                
    // Find the template you will use and send away ... 
                
    $messenger->prepare_file"message"true); 

                    if( 
    $messenger->execute("email") ) 
                    { 
                    
    $info '<p align="center"><font color="#003366">Je bericht is goed verzonden<br>en je zult een bevestiging ontvangen.<br>We beantwoorden je zo snel mogelijk.</font></p>'
                    } 
                    else 
                    { 
                    
    $info =  '<p align="center"><font color="#FF0000">Gelieve alle gegevens in te vullen!</font></p><p><a href="contact.html">[terug]</a>'
                    } 

                }
                
    // :( There was errors, put information about the errors again.
                
    else
                {

                
    $info "All data must be filled correctly before you send it!";

    $defaultVal[0] = $name;
    $defaultVal[1] = $email;
    $defaultVal[2] = $message;

                }

            } 
    ?>

    <script language="JavaScript" type="text/JavaScript">
    function clearDefault(el) {
    if (el.defaultValue==el.value) el.value = ""
    }
    </script>

    <table border="1" cellpadding="0" cellspacing="0">

    <form action="sendmail.php" method="POST">

    <input type="hidden" name="action" value="send">

                <tr><td colspan="2"><?php echo $info?></td></tr>

                <tr><td>Name:</td><td><input type="text" name="name" value="<?php echo $defaultVal[0?>" OnFocus="javascript:clearDefault(this);"></td></tr>

                <tr><td>Email:</td><td><input type="text" name="email" value="<?php echo $defaultVal[1?>" OnFocus="javascript:clearDefault(this);"></td></tr>

                <tr><td>Message:</td><td><textarea cols="15" rows="4" name="message"><?php echo $defaultVal[2?></textarea></td></tr>

                <tr><td colspan="2"><input type="submit" value="Send"></td></tr>

    </table>
    Best regards,
    mbrodin

  2. #12
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    if( !ereg("[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+", $email ) )
    That will reject many perfectly valid email addresses, such as fish@lion.co.uk or john.smith@example.com.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #13
    Join Date
    May 2007
    Location
    Sweden
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Quote Originally Posted by Twey View Post
    Code:
    if( !ereg("[[:alnum:]]+@[[:alnum:]]+\.[[:alnum:]]+", $email ) )
    That will reject many perfectly valid email addresses, such as fish@lion.co.uk or john.smith@example.com.
    Hi, Twey!

    No, it does not that!
    I have already test all kind of email addresses, and it's works perfectly.

    When I tested your example of emails it passed and was no wrong at it!

    Best regards,
    mbrodin

  4. #14
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It definitely shouldn't. [:alnum:] should match only alphanumerical characters, a set which does not include the full stop.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #15
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Quote Originally Posted by chechu View Post
    That one didn't work.
    Twey, it doesn' seem to work just separating the commas, as the second mailadress becomes subject.
    Mbrodin: can't use your script, as I have the following in it:
    Code:
    <script language="JavaScript" type="text/JavaScript">
    function clearDefault(el) {
    if (el.defaultValue==el.value) el.value = ""
    }
    </script>
    Hmm...
    Try this:

    PHP Code:
    <?php
    $htmlmess 
    'Unexpected Error while sending email.';
    if (
    $_POST['action'] == 'send'){

        if (
    $_POST['name'] != "je naam" && trim($_POST['name']) != "" && $_POST['email'] != "je e-mail adres" && trim($_POST['email']) != "" && trim($_POST['message']) != "") { 

            
    //PUT SENDERS HERE!
            
    $rec = array('info@cecicasariego.com''jurgen.schepers@euphonynet.be');
            
    //END
            
    $from $_POST['name'] . '<'$_POST['email'] . '>';
            
    $subject "je bericht aan hetbestevoordeel.be"
            
            
    $msg "
            Dit is een automatisch verzonden email. Gelieve hierop niet te antwoorden.
            
            Beste 
    {$_POST[name]},
            
            Bedankt voor je bericht aan hetbestevoordeel.be 
            We zullen je zo snel mogelijk beantwoorden.
            
            Dit was je bericht:
            
    {$_POST[message]}
            "


            foreach (
    $rec as $r) {
              
    $email mail($r,$subject,$body,"From: $from");
            }
            
            if (
    $email) {
                
    $htmlmess '<p style="color:#003366;text-align:center;">Je bericht is goed verzonden<br>en je zult een bevestiging ontvangen.<br>We beantwoorden je zo snel mogelijk.</p>';
            }
            
    //Indien problemen
            
    else{
                
    $htmlmess '<p style="color:#FF0000;text-align:center;">Gelieve alle gegevens in te vullen!</p><p><a href="contact.html">[terug]</a>';
            }
        }
    }
    ?> 
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Email Test</title>
    </head>

    <body>
    <?php echo $htmlmess?>
    </body>
    </html>
    I've tested this code, and it appears to be working.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  6. #16
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    Quote:
    Then you're doing something wrong. It's a comma-separated string, not a list of arguments:
    Code:
    "recipient1, recipient2, recipient3"
    That one indeed seems to work, but not with all mailadresses. Could that have something to do with spamfilters or php acceptance ?
    How c

  7. #17
    Join Date
    Jul 2006
    Location
    Antwerp, Belgium (Europe)
    Posts
    927
    Thanks
    121
    Thanked 2 Times in 2 Posts

    Default

    to continue previoous message ...:
    How can I place another mailadres as BCC ?

  8. #18
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You need to specify it manually in the POP headers (fourth argument).
    That one indeed seems to work, but not with all mailadresses. Could that have something to do with spamfilters or php acceptance ?
    Probably the former.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #19
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm not sure why having multiple email addresses would set off spam filters, specifically.

    Look up the mail function on php.net if you need more info on the additional headers. It can be a lot to remember and the page explains it well.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •