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