How to send email with codeigniter in linux localhost
there are 2 ways to test email on localhost one is mailcatcher you need to install mailcatcher on you development machine super simple smtp server, other is mailtrap i prefer mailtrap no need to install anything, create an account on mailtrap and you are ready to test your emails on localhost once you login you can get your account setting from mailtrap
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['newline'] = "rn";
if(ENVIRONMENT == 'development'){
$dev_config = Array(
'protocol' => 'smtp',
'smtp_host' => 'smtp.mailtrap.io',
'smtp_port' => 2525,
'smtp_user' => 'smtp_user_from_your_mailtrap',
'smtp_pass' => 'smtp_pass_from_your_mailtrap',
'crlf' => "\r\n",
'newline' => "\r\n"
);
$config = array_merge($config, $dev_config);
}
$this->email->initialize($config);
and happy local email testing.
PHP : send mail in localhost
It is configured to use localhost:25
for the mail server.
The error message says that it can't connect to localhost:25
.
Therefore you have two options:
- Install / Properly configure an SMTP server on localhost port 25
- Change the configuration to point to some other SMTP server that you can connect to
Related Topics
How to Convert PHP Date Formats to Gmt and Vice Versa
Get the Maximum Value from an Element in a Multidimensional Array
Redirect All Traffic to Index.PHP Using Mod_Rewrite
How to Find a Whole Word in a String in PHP Without Accidental Matches
Array_Key_Exists Is Not Working
How to Store and Retrieve Image Contents from the Database Using Laravel
Get Value from JSON Array in PHP
How to Pass Data Between Pages in PHP
Single and Double Quotes Together as HTML Attribute Value
Paypal Smart Subscribe Server Side
Split Keywords for Post PHP MySQL
Sending Multiple Attachment in an Email Using PHP
MySQL (Or PHP) Group Results by Field Data
PHP String Function to Get Substring Before the Last Occurrence of a Character
Remove Item from Array If It Exists in a 'Disallowed Words' Array