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

2022-01-17 00:00:00 email smtp cpanel php exim

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

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 )

有没有办法做到这一点?我真的很感激一些清晰的想法,因为我不擅长 exim 和其他东西.

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

附:我已经在 WHM 中有可用的 IP.

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

谢谢

推荐答案

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

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.

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

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.

相关文章