Welcome Guest, Not a member yet? Register   Sign In
1and1 email failure
#1

[eluser]BrokenLegGuy[/eluser]
Okay a client of mine has hosting at 1&1 and there is a contact page. I'm using the following code and no messages are being sent and I'm not getting any errors...

I have this exact same code on my site, hosting through DreamHost, and everything works. Can anyone shed some light on what is going on?

Thanks,

Ed

*Edit* by "my site" I am referring to a copy of my clients site on a sub domain of my site.





controllers/contact.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Contact extends MY_Controller{
public function __construct()
{
  parent::__construct();
  $this->load->library(array('form_validation', 'session', 'email'));
  $this->load->helper('email');
  // Your own constructor code
}
public function index()
{
  $field = $this->fields('email');
  if ($this->form_validation->run('send_email') == TRUE)
  {
   if( $this->send_mail($field['message'], $field['email'], $field['name'], $field['phone'], $field['business_name']) )
   {
    $data['message'] = 'Your message has been sent successfully.';
   }
   else
   {
    $data['message'] = 'There was a problem and your message could not be sent.';
   }
  }
  else
  {
   $data['message'] = (validation_errors()) ? validation_errors() : '';
  }
  $this->template->title('Contact Us');
  $this->template->set_layout('iframed');
  $this->template->build('contact', $data);
}
public function send_mail($user_message, $user_email, $user_name, $user_phone, $user_business_name)
{

  $data['contact_message'] = $user_message;
  $data['contact_email'] = $user_email;
  $data['contact_name'] = $user_name;
  $data['contact_phone'] = $user_phone;
  $data['contact_business_name'] = $user_business_name;
  $email_address = '[email protected]';
  $from_email ='[email protected]';
  $subject_email = 'Site Message Sent';
  $this->email->clear();

  $config['mailtype'] = 'html';
  $this->email->initialize($config);
  $this->email->set_newline("\r\n");
  $this->email->from($from_email, 'Site Support');
  $this->email->to($user_email);
  $this->email->bcc($email_address);
  $this->email->subject($subject_email);
  $this->email->message($this->load->view('email/site_message', $data, true));
  if ($this->email->send())
  {
   return TRUE;
  }
  else
  {
   return FALSE;
  }
  
  /*
  I even tried this. Yes, it is just the php mail() function and no dice


  $body = "Name: $user_name \n\nEmail: $user_email \n\nPhone: $user_phone \n\nBusiness Name:\n $user_business_name \n\nMessage:\n $user_message";
  $headers = 'From: Site Support <'.$from_email.'>' . "\r\n" . 'Reply-To: ' . $user_email;
  mail($email_address, $subject, $body, $headers); // Site Support copy
  mail($user_email, $subject, $body, $headers); // User copy
  */
}
function fields($form_name)
{
  $text_fields = array(
     'email' => array(
        'name',
        'email',
        'phone',
        'business_name',
        'message',
        'bot_check'
       )
  );
  foreach($text_fields[$form_name] AS $k => $v)
  {
   if($this->input->post($v))
   {
    $field_values[$v] = $this->input->post($v);
   }
  }
  return $field_values;
}
}


/* End of file contact.php
* Location: ./application/controllers/contact.php */




Theme © iAndrew 2016 - Forum software by © MyBB