在 Linux 上使用带有 SMTP 服务器的默认 PHP 邮件功能

2024-08-23php开发问题
7

本文介绍了在 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 邮件功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

PHP实现DeepL翻译API调用
DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以...
2025-08-20 php开发问题
168

PHP通过phpspreadsheet导入Excel日期数据处理方法
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的...
2024-10-23 php开发问题
287

mediatemple - 无法使用 codeigniter 发送电子邮件
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)...
2024-08-23 php开发问题
11

Laravel Gmail 配置错误
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)...
2024-08-23 php开发问题
16

将 PHPMailer 用于 SMTP 的问题
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)...
2024-08-23 php开发问题
4

关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)...
2024-08-23 php开发问题
17