Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require 'vendor/phpmailer/class.phpmailer.php';
- require 'vendor/phpmailer/class.phpmaileroauth.php';
- require 'vendor/phpmailer/class.phpmaileroauthgoogle.php';
- require 'vendor/phpmailer/class.smtp.php';
- require 'vendor/phpmailer/class.pop3.php';
- Class Sender {
- static public function __runtest() {
- $host = new smtpModel();
- $mail = new PHPMailer();
- $data = array(
- 'destinatario' => 'orlando@phpstaff.com.br',
- 'assunto' => 'ASSUNTO TESTE',
- 'mensagem' => 'MENSAGEM TESTE',
- 'responder' => ''
- );
- self::mail($data);
- }
- static public function mail($data) {
- //$data['destinatario' => 'fulado@gmail.com', 'assunto' => 'teste', 'mensagem' => 'mensagem teste', 'copia' => '', 'responder' => ''];
- $host = new smtpModel();
- $mail = new PHPMailer();
- $mail->isSMTP();
- // $mail->SMTPSecure = 'tls';
- $mail->SMTPDebug = 0;
- $mail->SMTPAuth = true;
- $mail->Host = $host->__get('host');
- $mail->Port = $host->__get('port');
- $mail->Username = $host->__get('email');
- $mail->Password = $host->__get('pass');
- $mail->setFrom($host->__get('email'), utf8_decode($host->__get('nome')));
- if (isset($data['responder']) && !empty($data['responder'])) {
- $mail->addReplyTo($data['responder']);
- }
- if (isset($data['copia']) && is_array($data['copia'])) {
- foreach ($data['copia'] as $copia) {
- $mail->addBCC("$copia");
- }
- }
- $mail->addAddress($data['destinatario']);
- $mail->Subject = utf8_decode($data['assunto']);
- //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
- $mail->msgHTML(utf8_decode($data['mensagem']));
- $mail->AltBody = '';
- //$mail->addAttachment('images/phpmailer_mini.png');
- if (!$mail->send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
- } else {
- return true;
- }
- }
- static public function multiple_mail($data) {
- //$data['destinatario' => 'fulado@gmail.com', 'assunto' => 'teste', 'mensagem' => 'mensagem teste', 'copia' => '', 'responder' => ''];
- $host = new smtpModel();
- $mail = new PHPMailer();
- $mail->isSMTP();
- // $mail->SMTPSecure = 'tls';
- $mail->SMTPDebug = 0;
- $mail->SMTPAuth = true;
- $mail->Host = $host->__get('host');
- $mail->Port = $host->__get('port');
- $mail->Username = $host->__get('email');
- $mail->Password = $host->__get('pass');
- $mail->setFrom($host->__get('email'), utf8_decode($host->__get('nome')));
- if (isset($data['responder']) && !empty($data['responder'])) {
- $mail->addReplyTo($data['responder']);
- }
- if (isset($data['copia']) && is_array($data['copia'])) {
- foreach ($data['copia'] as $copia) {
- $mail->addBCC("$copia");
- }
- }
- foreach ($data['destinatario'] as $destinatario) {
- $mail->addAddress($destinatario->usuario_email);
- }
- $mail->Subject = utf8_decode($data['assunto']);
- //$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
- $mail->msgHTML(utf8_decode($data['mensagem']));
- $mail->AltBody = '';
- //$mail->addAttachment('images/phpmailer_mini.png');
- if (!$mail->send()) {
- echo "Mailer Error: " . $mail->ErrorInfo;
- } else {
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement