使用“mail”或“sendmail”使用CodeIgniter发送电子邮件

时间:2012-07-25 15:15:45

标签: php codeigniter email smtp sendmail

我构建了一个需要发送电子邮件(低容量)的Intranet应用程序。我将无法使用组织的SMTP服务器,因此我需要通过sendmailmail发送这些电子邮件。

但是,当我将电子邮件配置为:

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

我明白了:

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.

当我使用时:

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

我明白了:

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

我是否应该在PHP中设置任何内容或签入phpinfo()以确定如何使其工作?

2 个答案:

答案 0 :(得分:10)

好的 - 这很简单。

对于任何遇到此问题的人:

  1. 首先检查是否安装了sendmail(实际上是Postfix)。我正在使用Ubuntu 11.x。
  2.   

    cd usr / sbin /

    1. 如果找不到sendmail,则需要安装
    2. sudo apt-get install postfix
      
      1. 我接受了对话框上的默认选项,一旦安装完成,发送的电子邮件没有问题。

答案 1 :(得分:1)

在windows os中,我尝试过sendmail类 你必须把sendmail.exe,sendmail.ini和其他两个.dll文件放在里面,

  

C:\瓦帕\ sendmail的

为gmail服务器配置sendmail.ini文件:

[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

然后编辑你的php.ini文件,该文件在

中可用
  

C:\瓦帕\ BIN \阿帕奇\ Apache2.2.17 \ BIN

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

现在运行您的项目,请参阅以下日志文​​件:

  

C:\瓦帕\ sendmail的\ error.log中   C:\瓦帕\ sendmail的\的debug.log

我认为这篇文章可以帮助你..