Welcome Guest, Not a member yet? Register   Sign In
send emails with the local protocol smtp
#1

Hi,
I'm new to codeigniter. I try to create a registration system. I am trying to follow this registration system. Everything works fine except sending emails. I check my mailbox, any mail exists.
here is the file email.php under application/config
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'localhost';
$config['smtp_port'] = 1025;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8'

And here is my controller signup:
PHP Code:
if($this->form_validation->run())
 
   {
 
     $data = array(
 
       'pseudo'=>$this->input->post('pseudo'),
 
       'email'=>$this->input->post('email'),
 
       'pass'=>sha1($this->input->post('pass'))
 
     );
 
     
      $this
->signup_model->signup($data);
 
     
      $this
->email->from('[email protected]','Mon site');
 
     $this->email->to($this->input->post('email'));
 
     $this->email->subject('Inscription');
 
     $this->email->message('okkkkkkkkkkkkkkk');
 
                     
      $this
->email->send();
 
     
      $data
['success'] = 'Inscription réussie';
 
     $data['titre'] = 'Inscription';
 
     $this->load->view('signup',$data);
 
   }
 
   else
    
{
 
     $data['titre'] = 'Inscription';
 
     $this->load->view('signup',$data);
 
   
here is the file php.ini under wamp
PHP Code:
[mail function]
; For 
Win32 only.
http://php.net/smtp
SMTP localhost
SMTP 
127.0.0.1 
http://php.net/smtp-port
smtp_port 1025

; For Win32 only.
http://php.net/sendmail-from
sendmail_from dhahri.nabila@gmail.com

; For Unix only You may supply arguments as well (default: "sendmail -t -i").
http://php.net/sendmail-path
;sendmail_path ="C:\wamp\sendmail\sendmail.exe" 
I just want a local test.
Reply
#2

(01-10-2016, 07:12 AM)WebAddict Wrote: Hi,
I'm new to codeigniter. I try to create a registration system. I am trying to follow this registration system. Everything works fine except sending emails. I check my mailbox, any mail exists.
here is the file email.php under application/config
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'localhost';
$config['smtp_port'] = 1025;
$config['mailtype'] = 'html';
$config['charset'] = 'utf-8'

And here is my controller signup:
PHP Code:
if($this->form_validation->run())
 
   {
 
     $data = array(
 
       'pseudo'=>$this->input->post('pseudo'),
 
       'email'=>$this->input->post('email'),
 
       'pass'=>sha1($this->input->post('pass'))
 
     );
 
     
      $this
->signup_model->signup($data);
 
     
      $this
->email->from('[email protected]','Mon site');
 
     $this->email->to($this->input->post('email'));
 
     $this->email->subject('Inscription');
 
     $this->email->message('okkkkkkkkkkkkkkk');
 
                     
      $this
->email->send();
 
     
      $data
['success'] = 'Inscription réussie';
 
     $data['titre'] = 'Inscription';
 
     $this->load->view('signup',$data);
 
   }
 
   else
    
{
 
     $data['titre'] = 'Inscription';
 
     $this->load->view('signup',$data);
 
   
here is the file php.ini under wamp
PHP Code:
[mail function]
; For 
Win32 only.
http://php.net/smtp
SMTP localhost
SMTP 
127.0.0.1 
http://php.net/smtp-port
smtp_port 1025

; For Win32 only.
http://php.net/sendmail-from
sendmail_from dhahri.nabila@gmail.com

; For Unix only You may supply arguments as well (default: "sendmail -t -i").
http://php.net/sendmail-path
;sendmail_path ="C:\wamp\sendmail\sendmail.exe" 
I just want a local test.

Setting up email on a development environment can be tricky if you're not on a real server (has qualified domain name). I'm assuming you are using a development environment because you are using WAMP, and real servers don't use WAMP. You might look at using FakeSMTP, or running all of your emails through a queue. The queue is ideal, because then you get to see the emails, attachments, etc. Unfortunately, you would probably have to create the queue yourself, as I am not aware that there is a FOSS option.
Reply
#3

I solved the issue. I changed email.php
PHP Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config['protocol'] = "smtp";
$config['smtp_host'] = "ssl://smtp.gmail.com";
$config['smtp_port'] = "465";
$config['smtp_user'] = "[email protected]";
$config['smtp_pass'] = "mypassword";
$config['charset'] = "utf-8";
$config['mailtype'] = "html";
$config['newline'] = "\r\n"


here is php.ini
PHP Code:
[mail function]
; For 
Win32 only.
http://php.net/smtp
SMTP ssl://smtp.gmail.com
http://php.net/smtp-port
smtp_port 465

; For Win32 only.
http://php.net/sendmail-from
sendmail_from firstname.lastname@gmail.com 

I changed the Gmail Account Setting "Allow less secure applications" to activated.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB