I am not a server admin at all, so forgive me.

I uploaded my website to a new windows server and am using mail(), but it's returning false. This indicates to me that the server is not properly set up to send emails. My php.ini has

SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

which I believe is the default.

I don't even know where to go from here. How can I check if SMTP is installed and working on port 25 of localhost? If it is, how can I get it to work with php mail()? Do I need to change something in apache?

  • There is another alternative which will require to change your code a bit though (but in my opinion it is worth it) -- do not use mail() but use dedicated classes to send emails, like PHPMailer(http://phpmailer.sourceforge.net/) or [SwiftMailer. Using them you can switch between using mail() or sending via SMTP directly very easy. If second (sending via SMTP) then you do not need to have local SMTP daemon. These classes (especially SwiftMailer) have much more to offer (attachments, encodings, extra security checks) -- more convenient comparing to mail(). – LazyOne Jun 18 '11 at 17:50

Windows doesn't (generally) run an SMTP daemon, so you'll need to set this SMTP value to the IP of a server that:

  1. Your server can connect directly to.
  2. Is running an SMTP daemon.
  3. Allows you to relay mail through it.
  • Is there any way I can set up the server to run an SMTP daemon that I can use? – Explosion Pills Jun 18 '11 at 16:11
  • 1
    Sure (just google "windows mail servers") but I wouldn't recommend it. You don't want to add "administering an email server" to your list of duties if you don't have to. You've probably already got access to an existing mail server that you can use (your corporate LAN's local mail host, your ISP's mail relay, etc.) -- you'll just need to find its IP. – Alex Howansky Jun 18 '11 at 16:20
  • That supplementary question was already answered on ServerFault in October 2009. – JdeBP Jun 18 '11 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.