在freebsd中为php mail()指定smtp服务器?

时间:2022-03-24 18:14:26

I have two dedicated servers, one of which is configured for sending email out (SPF, DKIM, other domain whitelisting methods, etc). I need to send email from both servers, but I want to send mail from both servers through the server that's been set up for it.

我有两个专用服务器,其中一个配置为发送电子邮件(SPF,DKIM,其他域白名单方法等)。我需要从两台服务器发送电子邮件,但我想通过已为其设置的服务器从两台服务器发送邮件。

It doesn't look like I can explicitly set an SMTP server directly in the mail function. Is there a way I can override the value set in php.ini, through .htaccess or something?

看起来我不能直接在邮件功能中明确设置SMTP服务器。有没有办法可以通过.htaccess或其他东西覆盖php.ini中设置的值?

2 个解决方案

#1


I would recommend not using the mail command and using a pre-built PHP mailing solution. There are 2 great recommendations at the following: Is this the correct way to send email with PHP?

我建议不要使用mail命令并使用预先构建的PHP邮件解决方案。以下是两条很好的建议:这是使用PHP发送电子邮件的正确方法吗?

In using a pre-built solution, you can have all of your mail go to the same server if you choose.

在使用预构建的解决方案时,如果您愿意,可以将所有邮件发送到同一服务器。

#2


I would recommend using ezcMail for sending emails. It has a clean object oriented prebuilt mailing package which is highly configurable.

我建议使用ezcMail发送电子邮件。它有一个干净的面向对象的预构建邮件包,具有高度可配置性。

#1


I would recommend not using the mail command and using a pre-built PHP mailing solution. There are 2 great recommendations at the following: Is this the correct way to send email with PHP?

我建议不要使用mail命令并使用预先构建的PHP邮件解决方案。以下是两条很好的建议:这是使用PHP发送电子邮件的正确方法吗?

In using a pre-built solution, you can have all of your mail go to the same server if you choose.

在使用预构建的解决方案时,如果您愿意,可以将所有邮件发送到同一服务器。

#2


I would recommend using ezcMail for sending emails. It has a clean object oriented prebuilt mailing package which is highly configurable.

我建议使用ezcMail发送电子邮件。它有一个干净的面向对象的预构建邮件包,具有高度可配置性。