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

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

问题描述

我正在开发一个 php/c# 项目,这是一个带有 Web 界面的电子邮件服务器,用于管理电子邮件服务器应用程序.

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

该程序应该可以在 windows 和 linux 上运行,但我主要是在 windows 上进行开发.

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

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

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

根据我在 Windows PHP 上搜索的内容,您可以选择要使用的 SMTP 服务器,但在 Linux 上您似乎没有此选项,因此当 PHP 发送电子邮件时,它会完全绕过我的程序.

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.

有没有办法让 PHP 使用您选择的 SMTP 服务器,我知道您可以使用 PEAR 覆盖 SMTP 设置,但我更希望标准的 PHP 邮件功能可以工作,以便 PHPBB 论坛等其他软件可以发送通过我的 SMTP 服务器而不是默认的 php 邮件发送电子邮件.

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?

推荐答案

您的标准 php 邮件函数只会发送到 php.ini 中定义为 sendmail _path 的任何内容

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

这通常是 sendmail -t -i

您需要配置 sendmail 以使用 smtp.

You would need to configure sendmail to use smtp.

FWIW,大多数从 PHP 应用程序发送大量邮件的开发人员都讨厌 mail(),而是使用提供更好的可配置性/可靠性的许多邮件库(或服务)之一.

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.

例如,您可以将 mail 函数通过管道传输到您自己的 PHP 脚本,并在该脚本中使用您想要的任何库来发送邮件(从而保留跨应用程序使用 mail() 函数).

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天全站免登陆