Guest User

Untitled

a guest
May 26th, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.65 KB | None | 0 0
  1. <?php
  2. require 'PHPMailer/PHPMailerAutoload.php';
  3.  
  4.  
  5. class Mail{
  6.    
  7.     function sendMail($name, $from, $subject, $message) {
  8.        
  9.         $mail = new PHPMailer;
  10.         //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  11.  
  12.         $mail->isSMTP();                                      // Set mailer to use SMTP
  13.         $mail->Host = 'mail.sfworx.com';  // Specify main and backup SMTP servers
  14.         $mail->SMTPAuth = true;                               // Enable SMTP authentication
  15.         $mail->Username = 'webmaster@sfworx.com';                 // SMTP username
  16.         $mail->Password = 'webmaster';                           // SMTP password
  17.         $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
  18.         $mail->Port = 465;                                    // TCP port to connect to
  19.  
  20.         $mail->From = 'webmaster@sfworx.com';
  21.         $mail->FromName = 'Mailer';
  22.         $mail->addAddress('info@sfworx.com', 'Joe User');     // Add a recipient
  23.         $mail->addReplyTo('webmaster@sfworx.com', 'No reply');
  24.         // $mail->addCC('cc@example.com');
  25.         // $mail->addBCC('bcc@example.com');
  26.         $mail->isHTML(true);                                  // Set email format to HTML
  27.  
  28.         $mail->Subject = $subject;
  29.         $mail->Body    = "Message from SFworx Website<br/><br/>".$message."<br/><br/>Name :"."<b>$name (<small>$from</small>)</b>";
  30.         /*$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';*/
  31.  
  32.         if(!$mail->send()) {
  33.            return false;
  34.         } else {
  35.            return true;
  36.         }
  37.     }
  38. }
  39.  
  40. $mail = new Mail();
  41. if (isset($_POST['email'])) {
  42.     echo $mail->sendMail($_POST['name'], $_POST['email'], $_POST['subject'], $_POST['message']);   
  43. }
Add Comment
Please, Sign In to add comment