如何从特定的IP地址发送电子邮件?

发布于 2024-10-05 01:36:20 字数 188 浏览 0 评论 0原文

我正在使用 cPanel/CentOS 运行 vps,并且我想动态选择 IP 地址以从 php 代码内部发送电子邮件。 (我对任何奇怪的方式持开放态度)

有什么办法可以做到这一点吗?我真的很感激一些清晰的想法,因为我不太擅长进出口和其他东西。

PS 我已经在 WHM 中拥有可用的 IP。

谢谢

I'm running a vps with cPanel/CentOS, And i want to dynamically choose the IP address to send an email from right inside the php code. ( i'm open to any weired ways )

Is there any way to do that? i would really appreciate some clear ideas as i'm not that good at exim and stuffs.

P.S. i already have available IPs in WHM.

Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

请你别敷衍 2024-10-12 01:36:20

您可以通过使用 sendmail 并传递参数来定义要使用的配置文件来实现此目的。在配置文件中,您可以使用 伪装和中继 选项与 CLIENT_OPTIONS(`Addr=aaa.bbb.ccc.ddd') 一起通过某个 IP 发送。

使用 PHP mail 时,使用 additional_parameters指定要使用的 sendmail 配置文件,并在该配置文件中使用上述选项对其进行配置。

You can achieve this by using sendmail and passing parameters to define the configuration file to use. Inside the configuration file you can use the Masquerading And Relaying options together with CLIENT_OPTIONS(`Addr=aaa.bbb.ccc.ddd') to send via a certain IP.

When using PHP mail use the additional_parameters to specify the sendmail config file to use and in that config file use the above options to configure it.

万水千山粽是情ミ 2024-10-12 01:36:20

PHP 无法控制发送邮件的 SMTP 服务器。您可以将 SMTP 服务器(sendmail、postfix、exim 等)绑定到特定接口,但这与 PHP 无关。 PHP 参与电子邮件发送过程纯粹是生成邮件,然后将其交给 SMTP 服务器进行实际发送。

PHP has no control whatsoever over the SMTP server that sends the mail. You can bind SMTP servers (sendmail, postfix, exim, etc...) to specific interfaces, but that's got nothing to do with PHP. PHP's involvement with the email sending process is purely to generate the mail and then hand it over to an SMTP server for actual delivery.

彩扇题诗 2024-10-12 01:36:20

这是一个想法。如果您需要从您可以控制的特定 IP 发送邮件,但该邮件的动力不是源自该 IP,而是来自某个 Web 界面或其他任何地方,您可以:

将邮件详细信息添加到DB 上的表,其中包含所需的 IP 地址作为字段。

设置 crons 在每个具有这些 IP 的机器上运行 php 脚本。

使用该脚本解析该表以查找需要来自该 IP 的任何邮件。

发送邮件。

Here is a thought. If what you need is to send the mail from a specific IP you have control over, but where the impetus for that mail doesn't originate from that IP, but from some web interface or whatever, you could:

Add the mail details to a table on a DB with the desired IP address as a field.

Setup crons to run a php script on each box with those IPs.

Parse over the table with that script to find any mail that needs to come from that IP.

Send the mail.

花之痕靓丽 2024-10-12 01:36:20

我在虚拟主机上有一个经销商帐户,例如,我的所有域都在同一 IP 号码下,那么无论我使用哪个域发送电子邮件,它都会在同一 IP 号码下发送,我认为它是由smtp 规范,您可以配置您的 smtp 以使用另一台服务器发送电子邮件,当然您有一个帐户。

还要创建一个表来控制您要使用哪个服务器来发送电子邮件。

I have a reseller account on a virtual host and all my domains for example are under the same IP number, then whatever domain I'm using to send an email, it will be sent under the same IP number, I think it is controlled by the smtp especification, you can configure your smtp to send email with another server where of course you have an account.

Also create a table to control what server you want to use to delivery yours email.

月下凄凉 2024-10-12 01:36:20

ClientPortOptions 和 DaemonPortOptions 是特殊情况,因为多个
可以定义客户端/守护进程。这可以通过

CLIENT_OPTIONS(`field1=value1,field2=value2,...')
DAEMON_OPTIONS(`field1=value1,field2=value2,...')

注意多个 CLIENT_OPTIONS() 命令(因此多个
允许 ClientPortOptions 设置)以便为每个端口提供设置
协议族(例如,一种用于 Family=inet,另一种用于 Family=inet6)。一个
对一个系列的限制仅影响该系列的传出连接
特定的家庭。

来源:http://www.sendmail.com/sm/open_source/docs/configuration_readme/

ClientPortOptions and DaemonPortOptions are special cases since multiple
clients/daemons can be defined. This can be done via

CLIENT_OPTIONS(`field1=value1,field2=value2,...')
DAEMON_OPTIONS(`field1=value1,field2=value2,...')

Note that multiple CLIENT_OPTIONS() commands (and therefore multiple
ClientPortOptions settings) are allowed in order to give settings for each
protocol family (e.g., one for Family=inet and one for Family=inet6). A
restriction placed on one family only affects outgoing connections on that
particular family.

Source: http://www.sendmail.com/sm/open_source/docs/configuration_readme/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文