dspld86684 2015-01-19 09:53
浏览 47

来自VMWare虚拟机(Win7)的PHP mail()函数

I have tried everything and looked everywhere (at least, I think I did!) but cannot find what I'm doing wrong. I'm persuaded it's something quite silly that I overlooked.

I am trying to send e-mails from a PHP application installed in a Windows 7 virtual machine. The host runs VMWare with a NAT & port forwarding to each of its virtual machines.

The virtual machine in question has its own IP inside the host's subnetwork. It runs WAMP with Apache / PHP / MySQL. To address its web server from the global network, one uses the host's IP and adds a specific port, which redirects to port 80 of the virtual machine.

For various reasons that I will not discuss here, I must use the PHP mail() function. I am well aware that this function is not optimal nor the best solution but I am forced to use it at the moment.

The host has access to an already existing (and immutable, I have no rights on it) SMTP server named "mail", port 25. Therefore, I set up the virtual machine's PHP configuration this way:

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = mail
; http://php.net/smtp-port
smtp_port = 25

Then I set up the NAT on the Vmware host so that the host machine's 25 port redirects to the virtual machine's 25 ports. (no other virtual machine needs it at the moment and I have limited control on the architecture of the vmware network)

User Blaatpraat reminded me that port forwarding is not needed in this case. Removed the NAT configuration.

Sadly, no luck. I get this error when I try to send an email from the virtual machine.

Warning: mail() [function.mail]: Failed to connect to mailserver at "mail" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in F:\wamp\www\mailtest.php on line 4

I must precise that the virtual machine can ping the "mail" server fine.

The same function works great if I try it from the host machine directly.

There is something I must be getting wrong in the port forwarding but I'm not sure what.

Can anyone see it? Is it even possible to do such a thing? Basically I'm just trying to access and use an existing SMTP server in the global network, accessible from the host, from inside the virtual machine.

Thank you very much in advance for your help

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 基于卷积神经网络的声纹识别
    • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
    • ¥100 为什么这个恒流源电路不能恒流?
    • ¥15 有偿求跨组件数据流路径图
    • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
    • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
    • ¥15 CSAPPattacklab
    • ¥15 一直显示正在等待HID—ISP
    • ¥15 Python turtle 画图
    • ¥15 stm32开发clion时遇到的编译问题