CodeIgniter Forums
Sending emails using CI - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Sending emails using CI (/showthread.php?tid=24077)



Sending emails using CI - El Forum - 10-30-2009

[eluser]max123[/eluser]
I'm new to CI. Could any one please tell me how to send emails starting with the very first step. I tried email class but it gives me errors


Sending emails using CI - El Forum - 10-30-2009

[eluser]khagendra[/eluser]
1. Load email library in ur controller.
Code:
$this->load->library('email');

2. use the following codes to send an email.
Code:
$this->email->from('sender email', 'Sender Name');   // $this->email->from('[email protected]', 'Your Name');
$this->email->to('receiver email');   //$this->email->to('[email protected]');

$this->email->subject('Subject of email');
$this->email->message('The message for the email.');

$this->email->send();

This will help to send an email.


Sending emails using CI - El Forum - 10-30-2009

[eluser]max123[/eluser]
I tried. But it gives following error

A PHP Error was encountered

Severity: Warning

Message: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set()

Filename: libraries/Email.php

Line Number: 1519


Sending emails using CI - El Forum - 10-30-2009

[eluser]praveens[/eluser]
you cont send mail using local system, upload your files to server and try it will works for u


Sending emails using CI - El Forum - 10-30-2009

[eluser]sl3dg3hamm3r[/eluser]
[quote author="praveens" date="1256917558"]you cont send mail using local system, upload your files to server and try it will works for u[/quote]

yes you can, but you need to install a SMTP-service on your local developer-machine. Furthermore, I suggest to use phpmailer - class instead of CI's built-in mailer-class. It is more reliable, and more powerfull, yet easy to use. The CI-stuff are very skilled developers, for sure. But you could fill books only about mail-headers in general. In this field, the people behind phpmailer have simply more experience. With phpmailer I was successfull with tasks which I failed with CI's mailer-class.