I am trying to customize the Reply-To header when an email is sent out to members of my website.
Right now, when I send out an email to my members, the reply-to is the same as the from, which is like this:
I want to change the reply-to address to "mywebsitename@gmail.com"from MyWebsite <noreply@mywebsite.com>
reply-to "noreply@mywebsite.com" <noreply@mywebsite.com>
The code looks like this:
Code:function sendmail() { $session = $this->session->userdata('adminid'); if(empty($session)) { $url = base_url() . 'adminLogin/'; redirect($url); } $data['pageTitle'] = 'Send Email'; $data['bodyId'] = 'manageuserspage'; $data['base'] = base_url(); if(isset($_POST['submitted'])) { if(!empty($_POST['em'])) { $em = $_POST['em']; foreach($em as $emv) { $tbl = 'members'; $in = array( 'email' => $emv ); $memid = $this->Get_model->get($tbl, $in); if($this->Get_model->err == true) { foreach($memid as $memidv) { $member = $memidv->member_id; } } $in = array( 'member_id' => $member, 'user_email' => $emv, 'message' => $_POST['text'], 'subject' => $_POST['title'] ); $tbl = 'sent_emails'; $this->Insert_model->insert($in, $tbl); if($this->db->affected_rows() > 0) { $config['protocol'] = 'mail'; $config['mailpath'] = '/usr/sbin/sendmail -t'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $config['mailtype'] = 'html'; $this->email->initialize($config); $from = "Our Team"; $subject = $_POST['title']; $msg = $_POST['text']; $this->email->from('noreply@mywebsite.com', 'mywebsite'); $this->email->to($emv); $this->email->subject($subject); $this->email->message($msg); if ( $this->email->send()) { $data['text'][] = 'Email has been sent'; } else { $data['text'][] = 'Error sending email'; } } } } }



Reply With Quote


Bookmarks