SHARE
TWEET

Untitled

a guest Jul 21st, 2017 571 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $email = new PHPMailer();
  2. $email->From      = 'you@example.com';
  3. $email->FromName  = 'Your Name';
  4. $email->Subject   = 'Message Subject';
  5. $email->Body      = $bodytext;
  6. $email->AddAddress( 'destinationaddress@example.com' );
  7.  
  8. $file_to_attach = 'PATH_OF_YOUR_FILE_HERE';
  9.  
  10. $email->AddAttachment( $file_to_attach , 'NameOfFile.pdf' );
  11.  
  12. return $email->Send();
  13.    
  14. <?php
  15.  
  16. require 'phpmailer/PHPMailerAutoload.php';
  17.  
  18. $mail = new PHPMailer;
  19.  
  20. //$mail->SMTPDebug = 3;                               // Enable verbose debug output
  21.  
  22. //$mail->isSMTP();                                      // Set mailer to use SMTP
  23. //$mail->Host = 'smtp.gmail.com';  // Specify main and backup SMTP servers
  24. //$mail->SMTPAuth = true;                               // Enable SMTP authentication
  25. //$mail->Username = '';                 // SMTP username
  26. //$mail->Password = '';                           // SMTP password
  27. //$mail->SMTPSecure = 'tls';                            // Enable TLS encryption, `ssl` also accepted
  28. //$mail->Port = 587;                                    // TCP port to connect to
  29.  
  30. $mail->From = 'from@example.com';
  31. $mail->FromName = 'Mailer';
  32. $mail->addAddress('name@domain.com', 'User');     // Add a recipient
  33. $mail->addAddress('ellen@example.com');               // Name is optional
  34. $mail->addReplyTo('info@example.com', 'Information');
  35. $mail->addCC('cc@example.com');
  36. $mail->addBCC('bcc@example.com');
  37.  
  38. $mail->addAttachment('');         // Add attachments
  39. $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
  40. $mail->isHTML(true);                                  // Set email format to HTML
  41.  
  42. $mail->Subject = 'Here is the subject';
  43. $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
  44. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  45.  
  46. if(!$mail->send()) {
  47.     echo 'Message could not be sent.';
  48.     echo 'Mailer Error: ' . $mail->ErrorInfo;
  49. } else {
  50.     echo 'Message has been sent';
  51. }
  52. ?>
  53.    
  54. /**
  55.  * Sets Mailer to send message using SMTP.
  56.  * @return void
  57.  */
  58. public function IsSMTP() {
  59.    $this->Mailer = 'smtp';
  60. }
  61.  
  62. /**
  63.  * Sets Mailer to send message using PHP mail() function.
  64.  * @return void
  65.  */
  66. public function IsMail() {
  67.   $this->Mailer = 'mail';
  68. }
  69.  
  70. /**
  71.  * Sets Mailer to send message using the $Sendmail program.
  72.  * @return void
  73.  */
  74. public function IsSendmail() {
  75.   if (!stristr(ini_get('sendmail_path'), 'sendmail')) {
  76.     $this->Sendmail = '/var/qmail/bin/sendmail';
  77.   }
  78.   $this->Mailer = 'sendmail';
  79. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top