August 3, 2012 4:23 am

Send Email with SMTP and PHP Mailer

In this tutorial we have a simple script which send email through SMTP (Send Mail Transfer protocol) with PHP Mailer. We need phpmailer library and bellow given code.

PHP Code

Simple PHP file

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.

Tutorial Categories:
  • daman sony

    This is not working!!
    Getting This error comes
    Fatal error: Class ‘SMTP’ not found in C:wampwwwFBSTOREphpmailerPHPclass.phpmailer.php on line 1147

    • huzoorbux

      Download the code and use it as it is just edit index.php file.

      • tẻtretre


        • tẻtretre


      • রাজিউল ইসলাম

        Its not working 🙁

    • tẻtretre

      yuytuytuyt tyretre re erterter ert ẻ432423432 32423423423423 423 423423

      • tẻtretre


        • tẻtretre


          • tẻtretre


          • tẻtretre


          • tẻtretre

            ewqewq rêwrew

      • tẻtretre


    • tẻtretre


      • tẻtretre


      • tẻtretre


  • kuldeep sonawane

    hi, nice tutorials. if it is possible write a tutorial on send MSG to phone. Thanks by the way good job!

  • Ghulam Ali

    amazing sir jee. i tried all others script but your script is working absoulutly amazing withour getting any error. thanx

  • Alok

    anyone can provide editing file of index.php file……because my code i notn working………my email id is [email protected]…(without username and password)

  • Hello sir I wan to know tht it may possibile to receive emails from smtp which email like [email protected] that is created from domain ?

  • Gautam

    i have download the code but it gives following error :

    SMTP Error: Could not authenticate.1

    how could i solve it

    is there any changes needed is “php.ini” file

  • dipjoy datta

    I am using same code but getting error like : SMTP Error: Could not connect to SMTP host. 1

    • that means your host is not valid post your host below.

  • freesonglyrics

    i am getting the this error
    SMTP Error: Could not authenticate.
    i am using windows server where windows 2012 is installed. What will be the solution to get rid of this problem.


    • Invalid login details you are sending please check your login details.

  • রাজিউল ইসলাম

    Its not working ,Please update a new one

  • nischaytv

    Warning: require_once(PHPMailer_v5.1/class.phpmailer.php): failed to open stream: No such file or directory in /home/appr7643/public_html/app/ma/index.php on line 2

  • nischaytv

    Fatal error: Class ‘SMTP’ not found in /home/aaaa/public_html/app/ma/PHPMailer-master/class.phpmailer.php on line 1466