Part of the EllisLab Network
   
 
Failed using an SMTP server to send emails
Posted: 06 October 2009 04:35 AM   [ Ignore ]  
Summer Student
Total Posts:  3
Joined  09-27-2009

Hi everyone…Pliz help me…
I’m new in CI and try to send email use smtp.
I didn’t get error code, and from the code below I always get “Message has been sent”
but the receiver didn’t get the email.

Can u help me what’s wrong with my code?

Here is my code :

$config = Array(
  ‘protocol’  => “smtp”,
  ‘smtp_host’ => “localhost”,
  ‘smtp_port’ => 25,
  ‘smtp_user’ => “”,
  ‘smtp_pass’ => “”,
  ‘smtp_timeout’ => 10,
  ‘priority’  => 3,
  ‘mailtype’  => “text/html”,
  ‘charset’  => “iso-8859-1”,
  ‘mailpath’  => “/usr/sbin/sendmail”,
  ‘wordwrap’  => TRUE
);
$this->load->library(‘email’, $config);
$this->email->set_newline(”\r\n”);
$this->email->from(‘webmaster@jawaban.com’, ‘Webmaster Jawaban.com’);
$this->email->to(‘mei2_chii@yahoo.com’,‘maylina.k@gmail.com’);
$this->email->subject($this->input->post(‘subject’));
$this->email->message($this->input->post(‘message’));
$this->email->send();

if (!$this->email->send())
  $vars[‘error_messages’] = show_error($this->email->print_debugger());
else
  $vars[‘success_messages’] = “Message has been sent”;

$this->email->clear();

Profile
 
 
Posted: 06 October 2009 06:28 AM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  12
Joined  09-19-2008

I don’t know if it was the forums, but the double and single quotes seemed to be off, I modified the code slightly and removed one of the sends you didn’t need and this seemed to work :-

  function index() {

      $config = Array(
      ‘protocol’  => ‘smtp’,
      ‘smtp_host’ => ‘ssl://smtp.googlemail.com’,
      ‘smtp_port’ => 465,
      ‘smtp_user’ => ‘xyz@gmail.com’,
      ‘smtp_pass’ => ‘passhere’,
      ‘smtp_timeout’ => 10,
      ‘priority’  => 3,
      ‘mailtype’  => ‘text/html’,
      ‘charset’  => ‘iso-8859-1’,
      ‘wordwrap’  => TRUE
      );
         
      $this->load->library(‘email’, $config);
      $this->email->set_newline(”\r\n”);
      $this->email->from(‘someone@gmail.com’, ‘Mr Smith’);
      $this->email->to(‘bill@domain.co.uk’, ‘Mr Jones’);
      $this->email->subject(‘This is the Subject’);
      $this->email->message(‘Message’);
     
      if (!$this->email->send()) {
      $vars[‘error_messages’] = show_error($this->email->print_debugger());
      } else {
      $vars[‘success_messages’] = “Message has been sent”;
      }
      $this->email->clear();
 
  }

Profile
 
 
Posted: 08 October 2009 02:13 AM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  3
Joined  09-27-2009

Wow Thanx…

I have tried it, and now my code works well…^^

Profile