Welcome Guest, Not a member yet? Register   Sign In
trouble sending email controller
#1

(This post was last modified: 10-05-2019, 09:54 PM by ciadmin.)

hi 
a bit of a novice, but can anyone give me an idea what might be wrong in this code? 
when submit button is pressed, there is no message or email sent ... 

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class ContactUs extends MY_Controller
{
function __construct()
{
parent::__construct();
//$this->load->model('front/homepage_model');
}

public function index()
{  
if(isset($_POST['submit']) && $_POST['submit'] == 'Contact1')
{
$name          = $this->input->post('name');
            $email        = $this->input->post('email');
            $message      = $this->input->post('msg');
            $subject      = $this->input->post('subject');
            $main_msg =`<b>Name : </b>`.$name.`  <br> <b>Email : </b> `.$email.` <br> Message : `.$message.``;
            $to      = '[email protected]';
            $subject      = 'Mail From [color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]@xxx.com[/font][/size][/color]';
            $headers = "From: sales@[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]xxx.com[/font][/size][/color].biz \r\n";
            $headers .= "Reply-To: sales[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif]@xxx.com[/font][/size][/color] \r\n";
            $headers .= 'Content-type:text/html; charset=ISO-8859-1\r\n';
            $headers .= 'MIME-Version: 1.0' . "\r\n";
            $mail    = $this->send_mail($to, $subject, $main_msg, $headers,$email);           
            if ($mail)
            {
                $this->session->set_flashdata('message', '<div class="alert alert-danger alert-dismissable fade in" style="color: #f1f1f1; background-color: #f25c27;"><a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a><strong>Thank You</strong> Your order request has been submited successfully, We will notify you soon.</div>');
                redirect(base_url('contactUs'));
            }
            else
            {
                $this->session->set_flashdata('message', '<div style="color: #f1f1f1; background-color: #f25c27;" class="alert alert-success alert-dismissable"><i class="fa fa-check"></i><button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><b> <strong>Sorry!</strong> Try out after some time, we cant process your request for  this time.</b></div>');
                redirect(base_url('contactUs'));
            }
}
  $this->show_view_front('front/contact_us',$this->data);

    }

}
/* End of file */
?>

Thank you

**EDIT: code tags added for readability**
Reply


Messages In This Thread
trouble sending email controller - by pmcr - 10-05-2019, 08:50 PM
RE: trouble sending email controller - by pmcr - 10-06-2019, 02:48 AM
RE: trouble sending email controller - by pmcr - 10-08-2019, 12:29 AM
RE: trouble sending email controller - by pmcr - 10-08-2019, 12:31 AM
RE: trouble sending email controller - by pmcr - 10-08-2019, 07:20 PM
RE: trouble sending email controller - by pmcr - 10-08-2019, 07:28 PM



Theme © iAndrew 2016 - Forum software by © MyBB