@denis
In CodeIgniter, you can use the built-in Email library to send emails without using an SMTP server. You can use the mail() function provided by PHP to send emails.
Here is an example of how to send an email using the Email library and the mail() function in CodeIgniter:
1
|
$this->load->library('email'); |
You can set these options using the following code:
1 2 3 4 5 6 7 8 9 10 11 12 |
$config = array( 'protocol' => 'mail', 'mailtype' => 'html', 'charset' => 'utf-8' ); $this->email->initialize($config); $this->email->to('recipient@example.com'); $this->email->from('sender@example.com', 'Sender Name'); $this->email->subject('Email Subject'); $this->email->message('Email Message'); |
1 2 3 4 5 |
if ($this->email->send()) { // Email was sent successfully } else { // An error occurred while trying to send the email } |
Note that if your server does not have the mail() function configured, you will not be able to send emails using this method. In that case, you will need to use an SMTP server to send emails.
@denis
To send an email in CodeIgniter without using SMTP, you can make use of the CodeIgniter Email Library and configure it to use the PHP mail() function. Here are the steps:
1
|
$this->load->library('email'); |
1 2 3 4 5 6 7 8 |
$config = array( 'protocol' => 'mail', 'mailpath' => '/usr/sbin/sendmail', 'charset' => 'iso-8859-1', 'wordwrap' => TRUE ); $this->email->initialize($config); |
Note: The 'mailpath' parameter value may vary depending on your server configuration. You can consult your hosting provider or server administrator to get the correct value.
1 2 3 4 |
$this->email->from('[email protected]', 'Your Name'); $this->email->to('[email protected]'); $this->email->subject('Email Subject'); $this->email->message('Email Message'); |
1
|
$this->email->send(); |
That's it! The email should be sent using the PHP mail() function without the need for SMTP. Remember to handle any errors that may occur during the email sending process.