How to send email via PHPMailer

Ask your Web Hosting Related Technical queries here
User avatar
admin
Site Admin
Posts: 35
Joined: Sun Jul 03, 2016 2:17 pm
Location: India
Contact:

How to send email via PHPMailer

Postby admin » Sun Jul 03, 2016 4:37 pm

In order to send email from Linux server from PHPMailer then one can use below mentioned sample script:


  1. <?php
  2. require("class.phpmailer.php");
  3.  
  4. $mail = new PHPMailer();
  5.  
  6. $mail->IsSMTP(); // send via SMTP
  7. $mail->Host = "mail.yourdomainname"; // SMTP servers
  8. $mail->SMTPAuth = true; // turn on SMTP authentication
  9. $mail->Username = "SMTP Email Username"; // SMTP username
  10. $mail->Password = "SMTP Email password"; // SMTP password
  11.  
  12. $mail->From = "From Email address";
  13. $mail->FromName = "Name to Display";
  14. $mail->AddAddress("Recipient Email address ","Recipient Name");
  15. $mail->AddCC(“CC Email Address”);
  16. $mail->AddBCC(“BCC Email address”);
  17. $mail->AddReplyTo("Reply to email address");
  18.  
  19. $mail->WordWrap = 50; // set word wrap
  20.  
  21. $mail->IsHTML(true); // send as HTML
  22.  
  23. $mail->Subject = "Subject";
  24. $mail->Body = "body";
  25.  
  26. if(!$mail->Send())
  27. {
  28. echo "Message did not sent <p>";
  29. echo "Mailer Error: " . $mail->ErrorInfo;
  30. exit;
  31. }
  32.  
  33. echo "Message has been sent";
  34.  
  35. ?>


Thanks,
Finest web hosting solution at the most affordable rates
Cheap Website Hosting
cheap VPS hosting india

Return to “Technical Support”

Who is online

Users browsing this forum: No registered users and 2 guests