gogoloi
gogoloi

Reputation: 667

can't send SMTP through codeIgniter

I try to send an email from codeIgniter but I get always next error message:

"FROM address must match your authenticated email user".

I have in config file just next lines for email:

$config['sender_email'] = '[email protected]';
$config['sender_name'] = 'Support'; 

And got that error message. Have add next line to my config file:

$config['protocol'] = 'smtp'; 
$config['smtp_host'] = 'localhost;    
$config['smtp_user'] = '[email protected]'; 
$config['smtp_pass'] = '123';
$config['smtp_port'] = '25'; 

Now I don't receive the error message but neither the email isn't send to required email address.

The code for email is:

$sender_email = $this->config->item('sender_email');
$sender_name = $this->config->item('sender_name');
$to = $user->user_email;
$subject = 'Password reset';
$html = "<p>Hi,".$user->user_name."</p>".
          p>blablabla<br/>".
    "<a href='".site_url('reset/'.$code)."'>Reset Password</a></p>".
    "<p>Best Regards,<br/>".$sender_name."</p>";

$this->email->from($sender_email,$sender_name);
$this->email->to($to); 
$this->email->subject($subject);
$this->email->message($html);   
$this->email->send();

Any suggestion, please?

Upvotes: 0

Views: 234

Answers (1)

user5139148
user5139148

Reputation:

Change $this->email->from($sender_email,$sender_name); with following code

$this->email->from('[email protected]',$sender_name);

and add replay to as follow

$this->email->reply_to($sender_email,$sender_name);

This will help you to fix it out. If not let us know about it. We'll help you out.

Upvotes: 1

Related Questions