thornhillguy Posted May 16, 2010 Share Posted May 16, 2010 I have a form that mails out to preset recipients, I need it to be able to send to recipients based on a selection from a list box. Below I have placed the section of code which deals with the out going mail, and included the added code which I tried to incorporate to add the selected recipient to the email. What happens is only the preset email addresses receive the form and the selected address is ignored. How do I get the recipient from the text box to be included in the array of email addresses that are sent out? Thank you in advance $data_email_sender = new FM_FormDataSender(sfm_readfile("./templ/orderform_email_subj.txt"),sfm_readfile("./templ/orderform_email_body.txt"),"%Email%"); $data_email_sender->AddToAddr("recipient one<[email protected]>"); $data_email_sender->AddToAddr("recipient two<[email protected]>"); //-----Added Sample Code Start--------- if(isset($_POST['sfm_form_submitted'])) { if($_POST['store'] == 'Queen') { $data_email_sender->AddToAddr("recipient three<[email protected]>"); } elseif($_POST['store'] == 'Disera') { $data_email_sender->AddToAddr("recipient four<[email protected]>"); } elseif($_POST['store'] == 'Wilson') { $data_email_sender->AddToAddr("recipient five<[email protected]>"); } } //-----Added Sample Code End --------- [code] From orderform-lib.php [code] ////////FormDataSender///////////// class FM_FormDataSender extends FM_ComposedMailSender { var $mail_subject; var $mail_template; var $dest_list; var $mail_from; var $file_upload; var $attach_files; function FM_FormDataSender($subj="",$templ="",$from="") { $this->mail_subject=$subj; $this->mail_template=$templ; $this->dest_list=array(); $this->mail_from=$from; $this->file_upload=NULL; $this->attach_files = true; } function SetFileUploader(&$fileUploader) { $this->file_upload = &$fileUploader; } function AddToAddr($toaddr) { array_push($this->dest_list,$toaddr); } function SetAttachFiles($attach_files) { $this->attach_files = $attach_files; } function SendFormData() { $this->InitMailer(); $this->ComposeMessage($this->mail_subject, $this->mail_template); if($this->attach_files && NULL != $this->file_upload ) { $this->file_upload->AttachFiles($this->mailer); } $from_merge = new FM_PageMerger(); $from_merge->Merge($this->mail_from,$this->formvars); $this->mail_from = $from_merge->getMessageBody(); foreach($this->dest_list as $to_address) { $this->logger->LogInfo("sending form data to: $to_address"); $this->SendMail($this->mail_from, $to_address); } } function Process(&$continue) { if(strlen($this->mail_template)<=0|| count($this->dest_list)<=0) { return false; } $continue = true; $this->SendFormData(); return true; } } [code] Link to comment https://forums.phpfreaks.com/topic/201983-need-help-modifying-mailto-form/ Share on other sites More sharing options...
andrewgauger Posted May 17, 2010 Share Posted May 17, 2010 I'll start with the obvious: is: sfm_form_submitted the correct name of the submit button (case sensitive) ['store'] == 'Queen' Is Queen the name of the option? Link to comment https://forums.phpfreaks.com/topic/201983-need-help-modifying-mailto-form/#findComment-1059641 Share on other sites More sharing options...
thornhillguy Posted May 20, 2010 Author Share Posted May 20, 2010 Double checked and everything seems to be correct, yes Queen is the name of the option I'll start with the obvious: is: sfm_form_submitted the correct name of the submit button (case sensitive) ['store'] == 'Queen' Is Queen the name of the option? Link to comment https://forums.phpfreaks.com/topic/201983-need-help-modifying-mailto-form/#findComment-1061073 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.