am trying to send emails using codeigniter email library to send emails to users using the following settings
$this->load->library('email');
$this->email->from('email@domain.com','Admin');
$this->email->to($recieverEmail);
$this->email->subject('Morgan MarketBook');
$this->email->message($message);
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'mail.server';
$config['smtp_port'] = 26 ;
$config['smtp_user'] = 'user' ;
$config['smtp_pass'] = 'password' ;
$config['newline'] = "\r\n";
?>
my problem that the received emails are in the junk mail and not in the inbox...what is causing this problem ?
Mail getting into junk instead of inbox isn't code related or codeigniter related for that matter. You have to follow some guidelines in order for the email not to be considered spam:
Some of these guidelines are:
- when sending html email, include also the text version of the mail
- when sending html email, keep the html and images to a minimum (don't include javascript)
- setup the mail server with spf and domain keys
- the "from" field should contain a valid email address (with the same domain as the mail server)
- if you send mass emails, try to limit the rate of sending
there are lots of guidelines for sending valid emails with php, just google "best practice for sending emails php"
Also, don't include your login credentials to your mail server.
Cheers
I beleive the problem is in your server, not in your CodeIgniter code. Try sending e-mail from the same e-mail address using a mail client. If you still receive the e-mail in the Junk mail you should contact your hosting provider and tell them about this problem, but my experience shows that they cannot do nothing about it.