www.webdeveloper.com
Results 1 to 8 of 8

Thread: Copy e-mail to sender

  1. #1
    Join Date
    Oct 2010
    Posts
    6

    Copy e-mail to sender

    Hello

    I have a form based on this script - http://www.web4future.com/easiest-form2mail.htm

    and... I have a problem. Please help.

    How can I add to the script option of sending a copy form to sender?

    Thanks .

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    22,330
    Since I don't know the specifics and am not about to download and install it just to figure it out, all I can suggest (pending someone who either knows that script or has time to wade through its code) is that, if it uses the PHP mail() function, you can add a "Cc:" mail header in the "additional headers" parameter for the mail() function.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  3. #3
    Join Date
    Oct 2010
    Posts
    6
    For example, how can I use these parameters/cunctions?

  4. #4
    Join Date
    Jul 2009
    Location
    Falls Church, Va.
    Posts
    780
    PHP Code:
    $to      'nobody@example.com';
    $subject 'the subject';
    $message 'hello';
    $headers 'From: webmaster@example.com' "\r\n" .
        
    'cc: webmaster@example.com' "\r\n" .
        
    'X-Mailer: PHP/' phpversion();

    mail($to$subject$message$headers); 
    The key is to use the headers for cc, bcc, etc. and to also include the \r\n which sends a return and newlines so most MTA's will know when each individual header terminates so they can parse the string properly.

    -jim
    Jim, Sr. Web Developer
    You know who you real friends are when you ask them to move your furniture or paint.

  5. #5
    Join Date
    Oct 2010
    Posts
    6
    Unfortunately, I don't know how to deal with this...
    Please help.
    I would greatly appreciate!

    My script:
    Code:
    <?php 
    # You can use this script to submit your forms or to receive orders by email.
    $MailToAddress = "you@site.com"; // your email address
    $redirectURL = "thankyou.htm"; // the URL of the thank you page.
    $MailSubject = "[Message from the contact form]"; // the subject of the email
    $sendHTML = FALSE; //set to "false" to receive Plain TEXT e-mail
    $serverCheck = TRUE; // if, for some reason you can't send e-mails, set this to "false"
    $w4fver =  "2.2";
    $ip = ($_SERVER['HTTP_X_FORWARDED_FOR'] == "" ? $_SERVER['REMOTE_ADDR'] : $_SERVER['HTTP_X_FORWARDED_FOR']);
    //function blockIP
    function blockip($ip) {
        $handle = @fopen("blockip.txt", 'a');
        @fwrite($handle, $ip."\n");
        @fclose($handle); 
    }
    $w4fx = stristr(file_get_contents('blockip.txt'),getenv('REMOTE_ADDR')); 
    if ($serverCheck) { 
        if (preg_match ("/".str_replace("www.", "", $_SERVER["SERVER_NAME"])."/i", $_SERVER["HTTP_REFERER"])) { $w4fy = TRUE; } else { $w4fy = FALSE; }
    } else { $w4fy = TRUE; }
    if (($w4fy === TRUE) && ($w4fx === FALSE)) {
    $w4fMessage = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html>\n<head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\"></head><body><font face=3Dverdana size=3D2>";
    if (count($_GET) >0) {
        reset($_GET);
        while(list($key, $val) = each($_GET)) {
            $GLOBALS[$key] = $val;
            if (is_array($val)) { 
                $w4fMessage .= "<b>$key:</b> ";
                foreach ($val as $vala) { 
                    $vala =stripslashes($vala);
                    $vala = htmlspecialchars($vala);
                    if (trim($vala)) { if (stristr($vala,"Content-Type:") || stristr($vala,"MIME-Version") || stristr($vala,"Content-Transfer-Encoding") || stristr($vala,"bcc:")) { blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); }    }
                    $w4fMessage .= "$vala, ";
                } 
                $w4fMessage .= "<br>\n";
            }     
            else {
                $val = stripslashes($val);
                if (trim($val)) { if (stristr($val,"Content-Type:") || stristr($val,"MIME-Version") || stristr($val,"Content-Transfer-Encoding") || stristr($val,"bcc:")) { blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); }    }
                if (($key == "Submit") || ($key == "submit")) { }     
                else {     if ($val == "") { $w4fMessage .= "$key: - <br>\n"; }
                        else { $w4fMessage .= "<b>$key:</b> $val<br>\n"; }
                }
            }
        } // end while
    }//end if
    else {
        reset($_POST);
        while(list($key, $val) = each($_POST)) {
            $GLOBALS[$key] = $val;
            if (is_array($val)) { 
                $w4fMessage .= "<b>$key:</b> ";
                foreach ($val as $vala) { 
                    $vala =stripslashes($vala);
                    $vala = htmlspecialchars($vala);
                    if (trim($vala)) { if (stristr($vala,"Content-Type:") || stristr($vala,"MIME-Version") || stristr($vala,"Content-Transfer-Encoding") || stristr($vala,"bcc:")) {blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); }    }                
                    $w4fMessage .= "$vala, ";
                } 
                $w4fMessage .= "<br>\n";
            }     
            else {
                $val = stripslashes($val);
                if (trim($val)) { if (stristr($val,"Content-Type:") || stristr($val,"MIME-Version") || stristr($val,"Content-Transfer-Encoding") || stristr($val,"bcc:")) {blockip($ip); die("ILLEGAL EXECUTION DETECTED!"); }    }
                if (($key == "Submit") || ($key == "submit")) { }     
                else {     if ($val == "") { $w4fMessage .= "$key: - <br>\n"; }
                        else { $w4fMessage .= "<b>$key:</b> $val<br>\n"; }
                }
            }
        } // end while
        }//end else
        $w4fMessage .= "<font size=3D1><br><br>\n Sender IP: ".$ip."</font></font></body></html>";
        $w4f_what = array("/To:/i", "/Cc:/i", "/Bcc:/i","/Content-Type:/i","/\n/");
        $name = preg_replace($w4f_what, "", $name);
        $email = preg_replace($w4f_what, "", $email);
    if (!$email) {$email = $MailToAddress;}
        $mailHeader = "From: $name <$email>\r\n";
        $mailHeader .= "Reply-To: $name <$email>\r\n";
        $mailHeader .= "Message-ID: <". md5(rand()."".time()) ."@". ereg_replace("www.","",$_SERVER["SERVER_NAME"]) .">\r\n";
        $mailHeader .= "MIME-Version: 1.0\r\n";
        if ($sendHTML) {
            $mailHeader .= "Content-Type: multipart/alternative;";            
            $mailHeader .= "     boundary=\"----=_NextPart_000_000E_01C5256B.0AEFE730\"\r\n";                    
        }
        $mailHeader .= "X-Priority: 3\r\n";
        $mailHeader .= "X-Mailer: PHP/" . phpversion()."\r\n";
        $mailHeader .= "X-MimeOLE: Produced By Web4Future Easiest Form2Mail $w4fver\r\n";
        if ($sendHTML) { 
            $mailMessage = "This is a multi-part message in MIME format.\r\n\r\n"; 
            $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730\r\n";
            $mailMessage .= "Content-Type: text/plain;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";            
            $mailMessage .= trim(strip_tags($w4fMessage))."\r\n\r\n";            
            $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730\r\n";            
            $mailMessage .= "Content-Type: text/html;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";            
            $mailMessage .= "$w4fMessage\r\n\r\n";            
            $mailMessage .= "------=_NextPart_000_000E_01C5256B.0AEFE730--\r\n";            
        }
        if ($sendHTML === FALSE) {
            $mailHeader .= "Content-Type: text/plain;   charset=\"ISO-8859-1\"\r\nContent-Transfer-Encoding: quoted-printable\r\n\r\n";            
            $mailMessage .= trim(strip_tags($w4fMessage))."\r\n\r\n";            
        }
    
        if (!mail($MailToAddress, $MailSubject, $mailMessage,$mailHeader)) { echo "Error sending e-mail!";}
        else { header("Location: ".$redirectURL); }    
    } else { echo "<center><font face=verdana size=3 color=red><b>ILLEGAL EXECUTION DETECTED!</b></font></center>";}
    ?>

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    22,330
    If I correctly understand what you want to do, just add a third line after these two:
    PHP Code:
        $mailHeader "From: $name <$email>\r\n";
        
    $mailHeader .= "Reply-To: $name <$email>\r\n";
    // add this line:
        
    $mailHeader .= "Cc: $name <$email>\r\n"
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

  7. #7
    Join Date
    Oct 2010
    Posts
    6
    ok, thank you!

  8. #8
    Join Date
    Oct 2012
    Posts
    4
    Hi, I have the same problem but my code look diferent then your

    <?
    $to = 'wilson@magega.com';
    $mailHeader = "Cc: $name <$email>\r\n"; I add this code but dont work here...
    $subject = 'Online Employees Time Cards';
    $message =

    How can I add a cc to these code please...

    Can some one help?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11342 seconds
  • Memory Usage 2,933KB
  • Queries Executed 15 (?)
More Information
Template Usage (34):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (8)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates