Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace salesApp\UtilityService;
- use PHPMailer;
- /**
- * Created by PhpStorm.
- * User: manoj
- * Date: 30/5/17
- * Time: 11:53 AM
- */
- class UtilityService
- {
- public function sendMail($body, $toEmail, $toName, $subject, $toCCEmail = null, $toCCName = null, $attachment = null, $attachmentName = null)
- {
- $mail = new PHPMailer();
- $mail->isSMTP();
- $mail->Host = 'smtp.gmail.com';
- $mail->SMTPAuth = true;
- $mail->Username = 'manoj@editsoft.in';
- $mail->Password = 'slim@shady1502';
- $mail->SMTPSecure = 'tls';
- $mail->Port = 587;
- $mail->setFrom('manoj@editsoft.in', 'Manoj Singh Rawat');
- $mail->addAddress($toEmail, $toName);
- if ($toCCEmail) {
- $mail->addCC($toCCEmail, $toCCName);
- }
- if ($attachment) {
- $mail->addAttachment($attachment, $attachmentName);
- }
- $mail->isHTML(true);
- $mail->Subject = $subject;
- $mail->Body = $body;
- if (!$mail->send()) {
- return $mail->ErrorInfo;
- }
- return true;
- }
- }
Add Comment
Please, Sign In to add comment