Guest User

Untitled

a guest
Feb 2nd, 2018
370
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. <?php
  2. App::uses('Component', 'Controller');
  3. #App::uses('Vendor','phpmailer/phpmailer/class.phpmailer');
  4. App::import('Vendor', 'phpmailer', array('file' => 'phpmailer'.DS.'phpmailer'.DS.'PHPMailerAutoload.php'));
  5.  
  6. class MailComponent extends Component {
  7.  
  8. public function send() {
  9. $mail = new phpmailer();
  10. //$mail->SMTPDebug = 3; // Enable verbose debug output
  11. $mail->isSMTP(); // Set mailer to use SMTP
  12. $mail->Host = 'smtp-mail.outlook.com'; // Specify main and backup SMTP servers
  13. $mail->SMTPAuth = true; // Enable SMTP authentication
  14. $mail->Username = 'cetokaiba2009@hotmail.com'; // SMTP username
  15. $mail->Password = 'linuxpdf193'; // SMTP password
  16. $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
  17. $mail->Port = 587; // TCP port to connect to
  18.  
  19. $mail->setFrom('cetokaiba2009@hotmail.com', 'Mailer');
  20. #$mail->addAddress('joe@example.net', 'Joe User'); // Add a recipient
  21. $mail->addAddress('ddanielsilva661@gmail.com'); // Name is optional
  22. //$mail->addReplyTo('info@example.com', 'Information');
  23. //$mail->addCC('cc@example.com');
  24. //$mail->addBCC('bcc@example.com');
  25.  
  26. //$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
  27. //$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
  28. $mail->isHTML(true); // Set email format to HTML
  29.  
  30. $mail->Subject = 'Here is the subject';
  31. $mail->Body = 'This is the HTML message body <b>in bold!</b>';
  32. $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
  33.  
  34. $feedback = $mail->send() ? 'Message has been sent' : 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo;
  35.  
  36. #if(!$mail->send()) {
  37. # $feedback = 'Message could not be sent.'.'Mailer Error: ' . $mail->ErrorInfo;
  38. #} else {
  39. # $feedback = 'Message has been sent';
  40. #}
  41.  
  42. return $feedback;
  43. }
  44. }
Add Comment
Please, Sign In to add comment