• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CodeIgniter Email Class Shows Email Credentials after $this->email->send()

I've searched for a solution for this but could not find one, so here goes...

I am not using print_debugger(), yet after I hit send on my form and the $this->email->send() function processes the email and sends it, the next window that opens in my browser shows all of my login credentials for the email account that I am using to send emails through. Messages are being sent successfully so I don't think this is an error. I would like for the user to be redirected to the prior page they were on with a message at the top that says 'Message Sent Successfully'.

First, does anyone know why I am seeing all my email credentials displayed when I'm not using the debugger and second, after the email controller runs when the user presses send, how do I build it that it redirects the user to the prior page with a message that says that the message was successfully sent (or an error indicating that it wasn't sent)?

First thing first:
post controller with coresponding method in here.

My apologies for not posting the actual code. I wrote this from work thinking I could get to my code from there, but I couldn't. This is controller that processes my email form. Like I said, the email sends successfully. However, the resulting page that shows in the browser shows all the email credentials I have set in my email.php config file.

function contact_seller() {
  //field name, error message, validation rules  
  $this->form_validation->set_rules('potential_customer_name', 'Name', 'trim|required');
  $this->form_validation->set_rules('potential_customer_message', 'Message', 'trim|required');
  $this->form_validation->set_rules('potential_customer_email', 'Email Address', 'trim|required|valid_email');
  $this->form_validation->set_rules('potential_customer_phone', 'Phone Number', 'valid_phone_number_or_empty');
  $this->form_validation->set_message('valid_phone_number_or_empty', 'The %s you provided is invalid.  Please use the format (###) ###-####.');
  if($this->form_validation->run() == FALSE)

   $this->email->from('[email protected]', 'Customer Contact');
   $this->email->subject('Contact from potential customer '.$this->input->post('potential_customer_name'));
   $this->email->message('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
         &lt;html &gt;
         &lt;meta http-equiv="Content-Type" c charset=UTF-8" /&gt;
         &lt;title&gt;Title Here&lt;/title&gt;
         body{font-family:Arial, Helvetica, sans-serif;font-size:24px;color:#50330a}.text_body{padding-left:20px;padding-right:20px;font-weight:lighter;margin-top:0px;font-size:.8em;text-shadow:0px 3px 5px rgba(186, 157, 119, 0.59)}.text_subtitle{font-stretch:expanded;font-weight:bold;text-shadow:0px 3px 5px rgba(186, 157, 119, 0.59)}.text_comingsoon{font-weight:bold;font-size:2em;text-shadow:0px 3px 5px rgba(186, 157, 119, 0.59)}
          <div class="page_container">
           <div class="page_body">
            <div class="text_subtitle">
             '.$this->input->post('potential_customer_name').' Is Interested In Your Listing!
            <div class="text_body">
             <p>'.$this->input->post('potential_customer_name').' | '.$this->input->post('seller_email').' | '.$this->input->post('potential_customer_phone').'</p>
   if($this->email->send() == TRUE)

The resulting page shows this at the top of the page:

$config['protocol'] = 'smtp'; $config['smtp_host'] = 'ssl://SMTPSERVERINFOHERE'; $config['smtp_user'] = 'SMTPUSERINFOHERE'; $config['smtp_pass'] = 'SMTPPASSWORDHERE'; $config['smtp_port'] = '465'; $config['mailtype'] = 'html'; $config['charset'] = 'utf-8';
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /home1/abcdefg/public_html/2013dev/application/config/email.php:7)

Filename: libraries/Session.php

Line Number: 675

Lastly, here is the code from my email.php config file:

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://SMTPSERVERINFOHERE';
$config['smtp_user'] = 'SMTPUSERINFOHERE';
$config['smtp_pass'] = 'SMTPPASSWORDHERE';
$config['smtp_port'] = '465';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';

Any thoughts on why the email credentials are displayed at the top of the subsequent page after the email sends? Any thoughts on how to properly display a message that either says 'Email sent successfully' or 'Email did not send, please try again later'?

Thank you!

What looks like this method:

function index($mypropertyid) {


  $session = array(
     'lastviewedproperty' => $mypropertyid

  //Converts MyPropertyID into PropertyID
  $query = $this->property_model->read_propertyid($mypropertyid);
  $propertyid = $query['propertyid'];
  //Checks if user already saved this listing if the user is logged in
  if($this->session->userdata('is_logged_in') == TRUE)
   $data['checksaved'] = $this->user_model->read_checksaved($propertyid);
   $data['checksaved'] = 0;
  //Gets listing details
  $data['location'] = $this->property_model->read_location($propertyid);
  $data['visits'] = $this->property_model->read_visits($propertyid);
  $data['listingstatus'] = $this->property_model->read_listingstatus($propertyid);
  $data['basicdetails'] = $this->property_model->read_basicdetails($propertyid);
  $data['additionaldetails'] = $this->property_model->read_additionaldetails($propertyid);
  $data['pictures'] = $this->property_model->read_pictures($propertyid);
  $data['primarypicture'] = $this->property_model->read_primarypicture($propertyid);
  $data['openhouses'] = $this->property_model->read_openhouses($propertyid);
  $data['taxes'] = $this->property_model->read_taxes($propertyid);
  $data['neighborhood'] = $this->property_model->read_neighborhood($propertyid);
  $data['schools'] = $this->property_model->read_schools($propertyid);
  $data['myid'] = $query['MyID'];
  $price = $data['listingstatus']['Price'];
  $zip = $data['location']['Zip'];
  $zwsid = 'MyZillowAPIKey'; //This is My Zillow ZWS-ID for API use.
  $down = '10'; //This is the downpayment percentage default.  Perhaps in the future can make this dynamic based on user input.
  $data['monthlypayments'] = $this->property_model->getmonthlypayments($price, $down, $zip, $zwsid);

  $data['main_content'] = 'property/detail';
  $this->load->view('includes/template_propertydetail', $data);

Very complex code. I will check it in the morning again. Too late for me now, sorry.


What is going on when you try to pass index function/method without sending mail - is that with no errors?

No worries. I appreciate you taking a look at it. Essentially all this code does is pulls all data about a property listing and loads that into various arrays that are used by the propertydetail view. This code works great to load the Property Detail page in the first place but the error comes when the page is reloaded after the email contact_seller method runs. The complexity of the code in the index function is pretty much just in the loading of arrays that the view uses to display all of the information it needs.

I got this resolved. Stupid mistake by me by not adding opening PHP tag to my email.php config file. Email.php config file should look like this:

&lt;?php // I did not have this before.  Rookie mistake.
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://SMTPSERVERINFOHERE';
$config['smtp_user'] = 'SMTPUSERINFOHERE';
$config['smtp_pass'] = 'SMTPPASSWORDHERE';
$config['smtp_port'] = '465';
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8';

Silly. Smile

Use some reach code editor so you can spot different colors between distinct string/data types in it.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.