How to specify outgoing IP address for mail in PHP

I have website with a form on it that links to PHP script.
Up until now the mail sends from the server it is located on but I need to change this for it to go from a specific IP . Not sure where or what the comand should go.

Please help

My current code is:

<?php mail("[email protected]","Enquiry from website","Enquiry website: Name: " . $_POST['name'] . " Surname: " . $_POST['surname'] . " email: " . $_POST['email'] . " telephone: " . $_POST['telephone'] . " Enquiry: " . $_POST['comments'] . " "); include("thanks.html"); ?>

I’m not sure that’s possible using the mail function. You’ll most likely need to switch to using SMTP. Using that, you can use a regular email service to send out the email.

With PHP mail, I don’t think their is a command, you’ll need to change the configuration settings of what ever mail server your using to define which IP it should send out on, if your machine has multiple IP addresses.

If you were to do raw SMTP you can probably do Socket binding to accomplish what you want…

http://www.php.net/manual/en/function.socket-bind.php

But I only don’t this before in .net, not in PHP so I can’t really help you there.

Sponsor our Newsletter | Privacy Policy | Terms of Service