Search code examples
ubuntusmtpsendmailphp

How do I specify to PHP that mail() should be sent using an external mail server?


I have my email hosted at Rackspace Email and would like to use that as my mail server for the contact form on my website.

Looking at the php.ini file, I'm only able to specify the sendmail_path on UNIX systems, from which I've read points to the program that actually sends mail on the server.

I do not want to send mail from my Ubuntu server since I'm not experienced enough to make a secure setup for email... I would like to relay everything to Rackspace's mail.emailsrvr.com.

My question is, how do I specify to the PHP setup on my server that the mail() function should be using an external mail server?


Solution

  • mail() is intended to hand off to a local SMTP server, and does a poor job of it. For proper mail support, use Swiftmailer or PHPMailer, both of which fully support external SMTP servers and are far easier to use (plus letting you do things like mixed text/html mails, attachments, etc...)