Everybody should be send email to every last client. The sending letters needs to accommodate whether client got mail or not. There are characterizes dsn is set True if server is advise gotten mail or not, generally false.
There are necessities to characterizes the host name, client and secret key, port number etc.We must design this esteem in the first place, else, it takes default values as it were. On the off chance that our server is custom then get mistake messages like:
Does not open socket. Your server doesnot configure using this method.
You can change configuration setting in the config file and intialates this config settings.
$config['protocol'] = 'send-mail';
$config['mailpath'] = '/usr/send/sendmail';
$config['charset'] = 'utf8';
$config['wordwrap'] = False;
$this->email->initialize($config);
There are additionally accessible config which is discretionary, it takes values default. We can tweaked mail work utilizing the diffrent values like encryption should be include or not or characterize scorch set like utf-8, iso charset. The prefrences, default esteem, choices are given beneath:
Preference | Default Value | Options | Description |
useragent | CodeIgniter | None | User Agent Name |
Protocol | mail, sendmail, or smtp | Mail Type | |
mailpath | usr/sbin/sendmail | None | The path save conformation mail report |
smtp_host | No Default | None | The host name |
smtp_user | No Default | None | User name |
smtp_pass | No Default | None | Password of user |
smtp_port | 25 | None | The port Number of port |
smtp_timeout | 5 | None | SMTP timout in seconds. After that SMTP call fail. |
smtp_keepalive | FALSE | TRUE or FALSE (boolean) | After sending operation, how much time alive SMTP connections. |
smtp_crypto | No Default | tls or ssl | Define security algorithm name |
wordwrap | TRUE | TRUE or FALSE (boolean) | |
wrapchars | 76 | ||
mailtype | text | text or html | Body content type it is text or html formate |
charset | $config['charset'] | Character set (utf-8, iso-8859-1, etc.). | |
validate | FALSE | TRUE or FALSE (boolean) | |
priority | 3 | 1,2,3,4,5 | Email Priority. 1 = highest. 5 = lowest. 3 = normal. |
crlf | \n | “\r\n” or “\n” or “\r” | Newline character. (Use “\r\n” to comply with RFC 822). |
newline | \n | “\r\n” or “\n” or “\r” | Newline character. (Use “\r\n” to comply with RFC 822). |
bcc_batch_mode | FALSE | TRUE or FALSE (boolean) | |
bcc_batch_size | 200 | None | Define maximum email send in one batch |
dsn | FALSE | TRUE or FALSE (boolean) |
Here is a basic example demonstrating how you might send email using default values. Note: This example assumes you are sending the email from one of your controllers.
$this->load->library('email');
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
NoTE: We must be include email library.