Welcome Guest, Not a member yet? Register   Sign In
Mail in Codeigniter
#1

[eluser]Joshi[/eluser]
Hi,

I have pasted my code below for your reference.
Code:
email.php File

$config = Array(
      'protocol' => 'smtp',
      'smtp_host' => 'ssl://smtp.gmail.com',
      'smtp_port' => 465,
      'smtp_user' => '[email protected]',
      'smtp_pass' => 'xxxxxx',
          'newline' => '\r\n',
          'charset' => 'iso-8859-1',
          'wordwrap' => TRUE,
          'mailtype' => 'text/html'
    );

when i send mail, i do get mail in my inbox, but the from field references the smtp_user mentioned in email.php file. I have designed a application where a business send emails to his customers. There are more than 1 business in my system.

This is what i get when a mail a sent.

from [email protected]
reply-to "zzz@yahoo.com" <zzz@yahoo.com>
to [email protected]

my code in php is as follows.

$this->email->from($busDetails->email);
$this->email->to($userDetails->email);
$this->email->subject($companyDetailsForBus->company." : ".$template->tempSub);
$this->email->message($tempDetails);
$this->email->set_newline("\r\n");
$this->email->send();

The mail shouldnot be from the [email protected] that comes from smtp_user. Instead the from field in the mail should be the business email address. Please help me to do this....
#2

[eluser]mddd[/eluser]
I don't think that is possible. It is not a CodeIgniter thing but a Gmail thing. Google won't let you use any sender without mentioning your own address. If they did, it would be too easy to use Gmail for spamming.
Use another gateway to send the mail. Set Codeigniter to use the php mail() function or use your provider's outgoing smtp.
#3

[eluser]whobutsb[/eluser]
You should print the debugger so you know what is happening in the background as well.

Code:
if(!$this->email->send()){
    echo $this->email->print_debugger();
}
#4

[eluser]2think[/eluser]
mddd is absolutely correct, this isn't a CI problem but is a feature of Google's (and others) SMTP implementation. If you're developing for businesses, there are many hosting companies that offer POP and SMTP access for domains hosted on their plans.
#5

[eluser]whobutsb[/eluser]
Checkout sendgrid.net, I just implemented it with some of my CI applications.




Theme © iAndrew 2016 - Forum software by © MyBB