在Linux上使用SMTP服务器的默认PHP邮件功能 [英] Use default PHP mail function with SMTP server on Linux

查看:149
本文介绍了在Linux上使用SMTP服务器的默认PHP邮件功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个php / c#项目,该项目是具有Web界面的Email Server,用于管理Email Server应用程序。



该程序应该在Windows和Linux上工作,但我一直在Windows中进行开发。



我没有在Linux中进行测试,发现了一个可怕的问题。



从我在Windows上搜索的PHP PHP可以选择要使用的SMTP服务器,但是看起来好像在Linux上没有此选项当PHP发送电子邮件时,它完全绕过我的程序。



有没有办法使PHP使用您选择的SMTP服务器,我知道您可以使用PEAR来覆盖SMTP设置,但我更喜欢标准的PHP邮件功能将会起作用,因此其他软件如PHPBB论坛将通过我的SMTP服务器而不是默认的php邮件发送电子邮件。



这是可能的东西,还是我唯一可以使用梨的选项?

解决方案

您的标准php邮件功能将发送到任何定义为php.ini中的sendmail _path



这通常是 sendmail -t -i



您需要配置sendmail才能使用smtp。



FWIW,大多数从PHP应用程序发送邮件的开发人员都会删除邮件(),而是使用许多邮件库(或服务)中的一种来提供更好的可配置性/可靠性。



例如,您可以将邮件功能管道到您自己的PHP脚本,并使用该脚本中的任何库来执行邮件发送(从而在应用程序之间保留使用mail())。 p>

I am working on a php/c# project which is an Email Server with a web interface to manage the Email Server application.

The program is supposed to work on windows and linux but I have been mostly doing my development in windows.

I've not come onto testing in Linux and have found a horrible problem.

From what I have googled on Windows PHP you can choose an SMTP server that you want to use, but it looks as if on Linux you don't have this option so when PHP sends an email it completely bypasses my program.

Is there a way to make PHP use an SMTP server of your choice, I know you can use PEAR to overrride the SMTP settings but I'd prefer that the standard PHP mail function would work so other software like PHPBB forum would send emails via my SMTP server instead of the default php mail.

Is this something that is possible or is my only option to use pear?

解决方案

You standard php mail function will just send to whatever is defined as the sendmail _path in php.ini

This is typically sendmail -t -i

You would need to configure sendmail to use smtp.

FWIW, most developer who do a lot of mail sending from PHP apps revile the mail() and instead use one of many mailing libraries (or services) which provide better configurability/reliability.

You could for example pipe the mail function to your own PHP script and use whatever library you wanted to in that script in order to do mail sending (and thus preserving the use of mail() function across applications).

这篇关于在Linux上使用SMTP服务器的默认PHP邮件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆