Guest User

Untitled

a guest
Jul 7th, 2017
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. namespace salesApp\UtilityService;
  4.  
  5. use PHPMailer;
  6.  
  7. /**
  8. * Created by PhpStorm.
  9. * User: manoj
  10. * Date: 30/5/17
  11. * Time: 11:53 AM
  12. */
  13. class UtilityService
  14. {
  15. public function sendMail($body, $toEmail, $toName, $subject, $toCCEmail = null, $toCCName = null, $attachment = null, $attachmentName = null)
  16. {
  17. $mail = new PHPMailer();
  18.  
  19. $mail->isSMTP();
  20. $mail->Host = 'smtp.gmail.com';
  21. $mail->SMTPAuth = true;
  22. $mail->Username = 'manoj@editsoft.in';
  23. $mail->Password = 'slim@shady1502';
  24. $mail->SMTPSecure = 'tls';
  25. $mail->Port = 587;
  26.  
  27.  
  28. $mail->setFrom('manoj@editsoft.in', 'Manoj Singh Rawat');
  29. $mail->addAddress($toEmail, $toName);
  30.  
  31. if ($toCCEmail) {
  32. $mail->addCC($toCCEmail, $toCCName);
  33. }
  34.  
  35. if ($attachment) {
  36. $mail->addAttachment($attachment, $attachmentName);
  37. }
  38. $mail->isHTML(true);
  39.  
  40.  
  41. $mail->Subject = $subject;
  42. $mail->Body = $body;
  43.  
  44.  
  45. if (!$mail->send()) {
  46. return $mail->ErrorInfo;
  47. }
  48. return true;
  49. }
  50.  
  51. }
Add Comment
Please, Sign In to add comment