Friday, February 01, 2013

Sending mail from localhost(WAMP) using SMTP Protocol and PHP(PEAR)

Note: In this tutorial im using configuring my wamp server and using Simple Mail Transfer Protocol using port 465.So this is a secure transmission and we wll be using gmail as the smtp host.

  • Pear is a framework and distribution of reusable PHP components.Download and install PEAR in your system.If you do not know how to install there is another alternative.Just downoad this go-pear.php which consists of a good UI for installation.
  • After installation, install mail, net mail and mail mime using your windows command prompt.
    • pear install Mail 
    • pear install Net_SMTP
    • pear install Mail_Mime(used for attachments)
  • Now open your text editor and enter the PHP code for sending the mail.You can View/Download the source code here.
  • Now alter the php.ini file to configure WAMP.To find your php.ini file leftclick wamp icon in the tray =>PHP=>php.ini
    • Search for include_path and uncomment it and give the link of the PEAR directory
    • Search for smtp and uncomment and modify all the values like port, from, host and...(Use the PHP code as reference)
  • Now you are good to go and try running the PHP file.Make sure your internet is on and enable POP in your gmail account.
    • For enabling POP for your gmail account go to Settings=>Forwarding and POP/IMAP and enable POP.
If you have any doubts or clarifications or if i my post is inadequate please feel free to comment.

Stay tuned for more.


0 comments:

Post a Comment