简体   繁体   中英

Sending email with CodeIgniter using 'mail' or 'sendmail'

I built an intranet app that needs to send email (low volume). I will not be able to use the SMTP server of my organization, so I need to send these emails via sendmail or mail .

However, when I config my email as:

$config['protocol'] = 'sendmail';

I get:

Exit status code: 127
Unable to open a socket to Sendmail. Please check settings.
Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method.

and when I use:

$config['protocol'] = 'mail';

I get:

Unable to send email using PHP mail(). Your server might not be configured to send mail using this method.

Is there anything I should setup in PHP or check in phpinfo() to figure out how to get this to work?

OK - this was simple.

For anyone who faces this issue:

  1. First check if sendmail (actually Postfix) is installed. I am using Ubuntu 11.x.

cd usr/sbin/

  1. If you can't find sendmail, then it needs to be installed
 sudo apt-get install postfix 
  1. I accepted the default options on the dialogs and once install was complete, emails sent without a problem.

In windows os , i have tried sendmail class.
You have to put sendmail.exe,sendmail.ini, and other two .dll files inside,

C:\\wamp\\sendmail

configure sendmail.ini file as follow for gmail server :

[sendmail]

smtp_server=smtp.gmail.com
smtp_port=587
smtp_ssl=tls
error_logfile=error.log
debug_logfile=debug.log
auth_username=mymail@gmail.com
auth_password=mypassword
hostname=smtp.gmail.com

then edit your php.ini file, that is available inside

C:\\wamp\\bin\\apache\\Apache2.2.17\\bin

sendmail_path="C:\wamp\sendmail\sendmail.exe -t -i"

Now run your project, see log files at:

C:\\wamp\\sendmail\\error.log C:\\wamp\\sendmail\\debug.log

i think this post can help you..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM