Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to integrate PHP Mailer

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 288
    Comment on it

    Hello Reader's! If you want to send email some other than php mail then php mailer is the best option. PHPMailer provides an object oriented interface, but in case of php mail() is not object oriented. Let's see how to integarte php mailer function.

    You can download PHPMailer from git from here

    Now extract the folder and create a php file with the following code:-

    1. <?php
    2.  
    3. require_once "vendor/autoload.php";
    4.  
    5. //PHPMailer Object
    6. $mail = new PHPMailer;
    7.  
    8. //From email address and name
    9. $mail->From = "from@yourdomain.com";
    10. $mail->FromName = "Full Name";
    11.  
    12. //To address and name
    13. $mail->addAddress("recepient1@example.com", "Recepient Name");
    14. $mail->addAddress("recepient1@example.com"); //Recipient name is optional
    15.  
    16. //Address to which recipient will reply
    17. $mail->addReplyTo("reply@yourdomain.com", "Reply");
    18.  
    19. //CC and BCC
    20. $mail->addCC("cc@example.com");
    21. $mail->addBCC("bcc@example.com");
    22.  
    23. //Send HTML or Plain Text email
    24. $mail->isHTML(true);
    25.  
    26. $mail->Subject = "Subject Text";
    27. $mail->Body = "<i>Mail body in HTML</i>";
    28. $mail->AltBody = "This is the plain text version of the email content";
    29.  
    30. if(!$mail->send())
    31. {
    32. echo "Mailer Error: " . $mail->ErrorInfo;
    33. }
    34. else
    35. {
    36. echo "Message has been sent successfully";
    37. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: