Super User is a question and answer site for computer enthusiasts and power users. 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

This is not a coding issue, so I think "superuser" is the best place to post this.

I have been trying to send email using PHP for about 1 week now, and still no success. My story so far:

  1. Trying to contact my hosting company about the SMTP server/port to put in my "php.ini" to send mails. They answer I have an unmanaged dedicated server, which means basically either I pay for their extra services or go --- myself.

  2. Trying to use random PHP scripts I found on google, have no idea how they work but they always end up in Spam folders, and are very often even ignored by big mailing systems like hotmail (they don't even show up at all most of the times)

  3. I tried the PHPMailer class that uses Google's SMTP server, but for some reason, google freeze and blocks access to any gmail account I make, once I type its password on the PHP script. I can't use that account anymore.

  4. I have one option left now, hosting my own SMTP server ? But have no idea how and seems like a lot of work to do.. I probably need weeks to learn how that works befor deciding if it was a good idea or not.

Why is it so hard to send a simple "Hello World" email using PHP, for free ? What can you guys recommend me to solve this issue ? Should I try to host my own SMTP server ? (I have a static IP and a dot com domain)

share|improve this question

closed as not constructive by nerdwaller, Scott, Brad Patton, Mokubai, 8088 Apr 12 '13 at 2:44

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

You said your emails are ending up in spam folders - they're being sent. I don't think you're sending them from a legitimate domain, so it's probably trying to do something like Reacen@, which would most likely be spam to all email clients. – cutrightjm Apr 12 '13 at 1:06
detail blog here: – Suresh Kamrushi Jun 22 '15 at 11:29

Sending email via php is easy... I think your question is more about how to get emails delivered to your recipients...

Do some googling on "email deliverability" and check out this post:

Also, using a reputable (paid) smtp service can help ... Sendgrid, socketlabs, authsmtp, etc. (I've used all 3)

share|improve this answer
  1. PHP scripts do not necessarily need an SMTP server to send mail. You can even send an email "by hand" from the command line. SMTP was specifically designed for this.

  2. An email can end up in spam folders for a number of reasons which can be more or less divided into two categories:

    Filtering based on the email itself

    A "trustworthy" email will have a subject, proper headers, be multipart mails rather than HTML-only, contain a minimum amount of text and avoid large images and some trigger words. The exact details depend on the spam filter's configuration.

    This will partially depend on the PHP script.

    Filtering based on the host

    When receiving incoming mail, many spam filters check if the IP (or the hostname or the sender domain) is blacklisted (check here) or whitelisted (apply, e.g., here) on some real-time list, if the host is allowed to send emails from that domain (SPF) and if the specific server is allowed to do so (DKIM).

  3. There's a recent tutorial here on how to do this.

    The line

    $mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for GMail

    seems particularly important, since it's not a part of most PHPMailer tutorials and failure to use SSL could be a reason for blocking a Google account.

  4. If you host an SMTP server on the same machine that's sending the mails via PHP, you'll have exactly the same problems.

Why is it so hard to send a simple "Hello World" email using PHP, for free ?

Spam. Lots of it. According to Trustwave's Spam Statistics, almost three out of every four emails are spam. This requires rather aggressive filtering to prevent all of us from getting drowned in spam.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged .