Mail() function with proxy server


I’ve been using our company mail server for quite some time for sending emails with the php mail()-function.
The last few weeks there are many failures such as missing mail bodies or mail attachments because of mail server malfunctions.
Instead, I want to send those mails to another mail server at the internet (e.g. my own ISP).

I can access the internet via my company intranet with the following proxy settings:
proxy_IP =
proxy_port = 8080

I’ve been looking at google and phpmailer. I also tried it with a local SMTP-server that acts as some sort of gateway, but I haven’t found a solution to connect to a SMTP through a proxy server?

Does anyone have any suggestion?

Thank you very much!



I’m hoping that Ann found a solution in the 5 and half years since she started this thread. :wink:

I ran into this same problem and from what I could tell is that the PHP mail() function uses the internal SMTP server (likely Sendmail) if on Linux.


So to use an external system you would need to use your own library such as phpmailer as you stated.

Inside of the configuration for my site it allows me to specify the SMTP server and authentication details.

Sample Code with including the phpmailer class library.

                               $mail = new PHPMailer();
                               $mail->From = ""
                               $mail->FromName = "";
                               $mail->Subject = "subject"
                               $mail->Body = "message";

Sorry I couldn’t help more, this is my limited knowledge and worked for me.