SHARE
TWEET

Untitled

a guest Jun 12th, 2019 319 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static function sendMail(MyEmail $myEmail) {
  2.        
  3.         $mail = new PHPMailer(true);                              // Passing `true` enables exceptions
  4.         $mail->CharSet = 'UTF-8';                                 // For accents
  5.  
  6.         try {
  7.             //Server settings
  8.             $mail->SMTPDebug = 0;                                 // Enable verbose debug output
  9.             $mail->isSMTP();                                      // Set mailer to use SMTP
  10.             $mail->Host = '205.0.211.32'; //'127.0.0.0';              // Specify main and backup SMTP servers
  11.             $mail->SMTPAuth = false;                              // Enable/Disable SMTP authentication
  12.         //    $mail->Username = 'user@example.com';               // SMTP username
  13.         //    $mail->Password = 'secret';                         // SMTP password
  14.         //    $mail->SMTPSecure = 'tls';                          // Enable TLS encryption, `ssl` also accepted
  15.             $mail->Port = 25;                                     // TCP port to connect to
  16.  
  17.             //Recipients
  18.             $mail->setFrom('textile@scaouest.fr', 'Application PF_Management');
  19.             $mail->addAddress($myEmail->getRecipient()['recipientAddress'], $myEmail->getRecipient()['recipientName']);     // Add a recipient
  20. //            $mail->addAddress('test@scaouest.fr', 'Civilité NOM Prénom');     // Add a recipient
  21.         //    $mail->addAddress('ellen@example.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.             //Attachments
  27.             if(!empty($myEmail->getAttachments())) {
  28.                 foreach($myEmail->getAttachments() as $attachmentPath) {
  29.                     $mail->addAttachment($attachmentPath);    // Add attachments w/ Optional name
  30.                 }
  31.             }
  32.  
  33.             //Content
  34.             $mail->isHTML(true);                                  // Set email format to HTML
  35.             $mail->Subject = $myEmail->getSubject();
  36.             $mail->Body    = $myEmail->getBody();
  37.             $mail->AltBody = $myEmail->getAltBody();
  38.  
  39.             $mail->send();
  40. //            echo 'Message has been sent';
  41.             return true;
  42.         } catch (Exception $e) {
  43.             return false;
  44.             //echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
  45.         }
  46.     }
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