Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I currently have a VPS with Slicehost, i am unable to send emails from my server using the PHP function mail. My server runs Centos 5.2, Apache 2, PHP 5.2 and MySQL 5. I don't know alot about servers/email, but i think the issue would be that im missing some obvious packages e.g. postfix, dovecot...

I have my MX records pointing to Rackspace email currently. Also i dont want my emails to be marked as spam, not sure what needs to be done to avoid this.



share|improve this question

I'm not entirely familiar with CentOS, but with Ubuntu, it doesn't come with an SMTP server by default. A simple one to install and use is sSMTP which I believe is under CentOS's repository. sSMTP is used strictly to send mail and I don't believe supports user authentication or mailboxes internally like a more full-blown SMTP server such as Postfix or QMail.

It is good though for using with PHP to send mail. I also believe you can configure sSMTP in /etc to relay the e-mail to another MX Mail server.

More information:

share|improve this answer

Excuse the long-windedness of my answer, just trying to be thorough. :) In the order of your question:

Sending Emails

The PHP mail() function calls the local sendmail command, which most MTAs replace with wrappers for their own binaries. Most distros also cleanly install their MTA of choice with default settings to work out of the box.

MTA Running

It seems that the default CentOS 5 MTA is sendmail. The first concern is why sendmail doesn't appear to be running on your box - did you specifically choose not to install it, or was it not your choice? Assuming Slicehost didn't remove it, you still need to confirm why/if it isn't running:

# rpm -qa | grep sendmail

If the output shows no sendmail installed, you can do the same for postfix and exim, the other likely MTAs on CentOS:

# rpm -qa | grep 'postfix\|exim'

If none are installed, I'd recommend installing postfix from a CentOS package, though YMMV.

If an MTA is installed, check if it is running:

# ps aux | grep 'post\|exim\|send'
# netstat -nupt -l | grep 25

If no process is running, and nothing is listening on port 25, yet the packages appear to be installed, check to see if an init script exists for the MTA in question:

# ls -alh /etc/init.d/{send,post,exim}*

If one doesn't, you'll need to erase the RPM and re-install, as there's no way to know what has and hasn't been messed with if this is a custom installation. If it does, try starting it:

# /etc/init.d/postfix start

The output with this should help you diagnose if there are any issues, otherwise it will start with no issue and doing a netstat again or a telnet to port 25 should show it listening. If there are issues, then I'd suggest you ask for help on this site or speak to Slicehost. If all is functional, one last thing is to make sure the init script is being loaded on boot:

# chkconfig --list postfix

The output will list the runlevels for the named init script, and though every distro is different, you should mostly see "on" next to the runlevel numbers, similar to:

# postfix         0:off   1:off   2:on    3:on    4:on    5:on    6:off

If you see too many "off"s, go ahead and add the default runlevels:

# chkconfig postfix on

MX, spam, et al

An MX is a Mail eXchange DNS record - in the context of this discussion it has nothing to do with sending mails. It is used by other parties trying to send mail to you. Regarding the spam - that again is not something you would control on your side. Imagine anyone with access to a *nix box being able to mark their outbound mail as "not spam"...

More Information

Finally, the portion I should've started with: assuming the issue isn't an MTA problem, you need to provide more information for anyone to be able to help you. Yes, you're unable to send mail, but what are the symptoms? Does PHP give you an error response? If so, what is it? If not, have you enabled full debug output? Do you see anything at all in any server logs? Etc.

Hope this helps.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.