Search:
Main Menu
Login | RSS |

Quick PHP Code Tips and Examples

PHP Programming Tips, Tutorials and Source Code Examples for newbie

5 Reasons to avoid mail() in PHP scripts

May 2nd, 2007 by Jon Moffet

Here are my 5 reasons why I do not prefer to use mail() function to send emails from my PHP scripts :

  • Depends too much on your (shared hosting) web server to send email
  • Not flexible - you can't choose which SMTP server to use to send your mails
  • Not portable - Windows testing server may have problem with mail() code
  • Vulnerable - mail() code is notoriously known for its vulnerability to Email Injection attacks
  • Hard to use/Cryptic - although seems simple, mail() is hard to use. You have to be very careful
    in structuring your mail headers to send emails to multiple senders or sending html emails (or attachment)

Another compelling reason is :
Risk being marked as Spam
Your emails risked of being marked as SPAM in shared hosting environment, this is because your email is sent from the same server that (probably) hosted site that send spam emails.

RBL Anti-Spam services might mark your email as spam and it will end up in bulk-email folder in your favorite email clients.

So the best solution is to use PHPMailer class which enables you to send email through your own private SMTP server and disassociate yourself from all those spammers.

Please avoid mail() as it encourage email spams.

ps: I do not deny the effectiveness of mail() if it is coded properly. However, most people tends to use mail() blindly without proper checkups and input validation which can lead to email injection attacks and other abuses.

Tags: , , , , , , ,

Bookmark Post:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • NewsVine
  • Reddit
  • Netvouz
  • Spurl
  • Furl
  • digg
  • YahooMyWeb
  • del.icio.us

Posted in Uncategorized |

Related Posts

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.