Пример #1
2
 function enviar()
 {
     if ($this->cliente->getAccessToken()) {
         $service = new Google_Service_Gmail($this->cliente);
         try {
             $mail = new PHPMailer();
             $mail->CharSet = "UTF-8";
             $mail->From = Contants::FROM;
             $mail->FromName = Contants::ALIAS;
             $mail->AddAddress($this->destino);
             $mail->AddReplyTo(Contants::FROM, Contants::ALIAS);
             $mail->Subject = $this->asunto;
             $mail->Body = $this->mensaje;
             $mail->preSend();
             $mime = $mail->getSentMIMEMessage();
             $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
             $mensaje = new Google_Service_Gmail_Message();
             $mensaje->setRaw($mime);
             $service->users_messages->send('me', $mensaje);
             $r = 1;
         } catch (Exception $e) {
             print $e->getMessage();
             $r = 0;
         }
     } else {
         $r = -1;
     }
     return $r;
 }
Пример #2
1
 static function sendActivationMail2($destinatario, $asuntoMensaje, $contenidoMensaje)
 {
     session_start();
     $activacion = sha1($destinatario . Constant::SEMILLA);
     $origen = "*****@*****.**";
     $alias = "Jonathan";
     $destino = $destinatario;
     $asunto = $asuntoMensaje;
     $mensaje = $contenidoMensaje;
     require_once 'googleMail/Google/autoload.php';
     require_once 'googleMail/class.phpmailer.php';
     //las últimas versiones también vienen con autoload
     $cliente = new Google_Client();
     $cliente->setApplicationName(Constant::APPLICATIONAME);
     $cliente->setClientId(Constant::CLIENTID);
     $cliente->setClientSecret(Constant::SECRETCLIENTID);
     $cliente->setRedirectUri(Constant::URI);
     $cliente->setScopes('https://www.googleapis.com/auth/gmail.compose');
     $cliente->setAccessToken(file_get_contents('../clases/googleMail/token.conf'));
     if ($cliente->getAccessToken()) {
         $service = new Google_Service_Gmail($cliente);
         try {
             $mail = new PHPMailer();
             $mail->CharSet = "UTF-8";
             $mail->From = $origen;
             $mail->FromName = $alias;
             $mail->AddAddress($destino);
             $mail->AddReplyTo($origen, $alias);
             $mail->Subject = $asunto;
             $mail->Body = $mensaje;
             $mail->preSend();
             $mime = $mail->getSentMIMEMessage();
             $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
             $mensaje = new Google_Service_Gmail_Message();
             $mensaje->setRaw($mime);
             $service->users_messages->send('me', $mensaje);
             echo "correo enviado correctamente";
         } catch (Exception $e) {
             print "Error en el envio del correo " . $e->getMessage;
         }
     } else {
         echo "no conectado con gmail";
     }
 }
Пример #3
0
 function send()
 {
     if ($this->cliente->getAccessToken()) {
         $service = new Google_Service_Gmail($this->cliente);
         try {
             $mail = new PHPMailer();
             $mail->CharSet = "UTF-8";
             $mail->From = $this->from ? null : Constant::_MAILFROM;
             $mail->FromName = $this->alias ? null : Constant::_MAILALIAS;
             $mail->AddAddress($this->to);
             $mail->AddReplyTo($this->from ? null : Constant::_MAILFROM, $this->alias ? null : Constant::_MAILALIAS);
             $mail->Subject = $this->subject;
             $mail->Body = $this->message;
             $mail->preSend();
             $mail->isHTML();
             $mime = $mail->getSentMIMEMessage();
             $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
             $mensaje = new Google_Service_Gmail_Message();
             $mensaje->setRaw($mime);
             $service->users_messages->send('me', $mensaje);
             $r = 1;
         } catch (Exception $e) {
             print $e->getMessage();
             $r = 0;
         }
     } else {
         $r = -1;
     }
     return $r;
 }
Пример #4
0
 function sendMail($origen, $alias, $destino, $asunto, $mensaje)
 {
     if ($this->client->getAccessToken()) {
         $service = new Google_Service_Gmail($this->client);
         try {
             $mail = new PHPMailer();
             $mail->CharSet = "UTF-8";
             $mail->From = $origen;
             $mail->FromName = $alias;
             $mail->AddAddress($destino);
             $mail->AddReplyTo($origen, $alias);
             $mail->Subject = $asunto;
             $mail->Body = $mensaje;
             $mail->preSend();
             $mime = $mail->getSentMIMEMessage();
             $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
             $mensaje = new Google_Service_Gmail_Message();
             $mensaje->setRaw($mime);
             $service->users_messages->send('me', $mensaje);
             return 1;
         } catch (Exception $e) {
             return 0;
         }
     } else {
         return -1;
     }
 }
Пример #5
0
 public function sendEmail($data)
 {
     $service = Mailbox::getGmailService();
     $message = new \Google_Service_Gmail_Message();
     $boundary = uniqid(rand(), true);
     $subject = $data['subject'];
     $to = $data['to'];
     $message_text = $data['message'];
     $data['cc'] = str_replace(" ", "", $data['cc']);
     $cc_tmp = explode(';', $data['cc']);
     $cc = implode(", ", $cc_tmp);
     $data['bcc'] = str_replace(" ", "", $data['bcc']);
     $bcc_tmp = explode(';', $data['bcc']);
     $bcc = implode(", ", $bcc_tmp);
     $line = "\n";
     $raw = "to: {$to}" . $line;
     if ($data['cc']) {
         $raw .= "cc: " . $cc . $line;
     }
     if ($data['bcc']) {
         $raw .= "bcc: " . $bcc . $line;
     }
     $raw .= "subject: {$subject}" . $line;
     if (!is_null($data['attachments'][0])) {
         $raw .= 'Content-type: multipart/mixed; boundary="' . $boundary . '"' . $line;
         $raw .= $line . "--" . $boundary . $line;
         $raw .= 'Content-Type: text/plain; charset=utf-8' . $line;
         $raw .= 'Content-Transfer-Encoding: 7bit' . $line . $line;
         $raw .= $message_text . $line;
         // $raw .= $line."--".$boundary.$line;
         // $raw .= 'Content-Type: text/html; charset=utf-8'.$line;
         // $raw .= $message_text.$line;
         foreach ($data['attachments'] as $attachment) {
             $location = public_path() . '/email_attachments/sent/';
             $filename = str_random(20) . '-' . $attachment->getClientOriginalName() . "." . $attachment->guessClientExtension();
             $file_location = $attachment->move($location, $filename);
             $mimetype = $attachment->getClientMimeType();
             $raw .= $line . "--" . $boundary . $line;
             $raw .= 'Content-Type: ' . $mimetype . '; name="' . $attachment->getClientOriginalName() . '";' . $line;
             $raw .= 'Content-ID: <' . $this->email . '>' . $line;
             $raw .= 'Content-Description: ' . $attachment->getClientOriginalName() . ';' . $line;
             $raw .= 'Content-Disposition: attachment; filename="' . $attachment->getClientOriginalName() . '"; size=' . $attachment->getClientSize() . ';' . $line;
             $raw .= 'Content-Transfer-Encoding: base64' . $line . $line;
             $raw .= chunk_split(base64_encode(file_get_contents($location . $filename)), 76, "\n") . $line;
             $raw .= '--' . $boundary . $line;
         }
         // echo '<pre>';
         // die(print_r($raw));
     } else {
         $raw .= "MIME-Version: 1.0" . $line . $line;
         $raw .= $message_text;
     }
     dd($raw);
     $message->setRaw(rtrim(strtr(base64_encode($raw), '+/', '-_'), '='));
     try {
         $service->users_messages->send("me", $message);
     } catch (Exception $e) {
         print 'An error occurred: ' . $e->getMessage();
     }
 }
Пример #6
0
 static function sendMail($destino)
 {
     $origen = "*****@*****.**";
     $asunto = "Validación";
     $sha1 = sha1($destino . Constants::SEMILLA);
     $mensaje = "Hola. Se ha dado de alta en la base de datos. \n        Ya solo queda activar la cuenta pulsando sobre el siguiente enlace:\n        https://usuarios-carlosgrgr.c9users.io/phpactivar.php?email={$destino}&sha1={$sha1}";
     $cliente = new Google_Client();
     $cliente->setApplicationName('ProyectoEnviarCorreoDesdeGmail');
     $cliente->setClientId('144315405047-hu44apt2g5q2akupkjalbk66ctmm0irb.apps.googleusercontent.com');
     $cliente->setClientSecret('A40mAiwufd0-UvupZDkCMJCE');
     $cliente->setRedirectUri('https://gestionusuario-carlosgrgr.c9users.io/oauth/guardar.php');
     $cliente->setScopes('https://www.googleapis.com/auth/gmail.compose');
     $cliente->setAccessToken(file_get_contents('./oauth/token.conf'));
     if ($cliente->getAccessToken()) {
         $service = new Google_Service_Gmail($cliente);
         try {
             $mail = new PHPMailer();
             $mail->CharSet = "UTF-8";
             $mail->From = $origen;
             //El correo que manda
             $mail->FromName = $alias;
             //El nombre con el que llega
             $mail->AddAddress($destino);
             //A donde se manda
             $mail->AddReplyTo($origen, $alias);
             $mail->Subject = $asunto;
             //Asunto
             $mail->Body = $mensaje;
             //Mensaje
             $mail->preSend();
             $mime = $mail->getSentMIMEMessage();
             $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
             $mensaje = new Google_Service_Gmail_Message();
             $mensaje->setRaw($mime);
             $r = $service->users_messages->send('me', $mensaje);
             echo "se ha enviado";
         } catch (Exception $e) {
             print "Error en el envío de correo" . $e->getMessage();
         }
     } else {
         echo "no conectado con gmail";
     }
     return $r = $r["labelIds"][0];
 }
Пример #7
0
 static function sendMail($destino)
 {
     $origen = "*****@*****.**";
     $asunto = "WU User";
     $destino = $destino;
     $alias = "Mike";
     $sha1 = sha1($destino . Constants::SEMILLA);
     $mensaje = "Saludos Usuario. Para completar su registro en WU pulse el siguiente enlace:\n        https://wusuario-miguelfdez79.c9users.io/wu/phpdardealta.php?email={$destino}&sha1={$sha1}";
     $cliente = new Google_Client();
     $cliente->setApplicationName('ProyectoEnviarCorreo');
     $cliente->setClientId('560186546771-323f2k7vuhfr2uma1gdc3o09gjgtuagr.apps.googleusercontent.com');
     $cliente->setClientSecret('dtpKnyCb9cuaDontUMC-wntA');
     $cliente->setRedirectUri('https://wusuario-miguelfdez79.c9users.io/oauth/guardar.php');
     $cliente->setScopes('https://www.googleapis.com/auth/gmail.compose');
     $cliente->setAccessToken(file_get_contents('../oauth/token.conf'));
     if ($cliente->getAccessToken()) {
         $service = new Google_Service_Gmail($cliente);
         try {
             $mail = new PHPMailer();
             $mail->CharSet = "UTF-8";
             $mail->From = $origen;
             $mail->FromName = $alias;
             $mail->AddAddress($destino);
             $mail->AddReplyTo($origen, $alias);
             $mail->Subject = $asunto;
             $mail->Body = $mensaje;
             $mail->preSend();
             $mime = $mail->getSentMIMEMessage();
             $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
             $mensaje = new Google_Service_Gmail_Message();
             $mensaje->setRaw($mime);
             $r = $service->users_messages->send('me', $mensaje);
             echo "se ha enviado";
         } catch (Exception $e) {
             print "Error en el envío de correo" . $e->getMessage();
         }
     } else {
         echo "no conectado con gmail";
     }
     return $r["labelIds"][0];
 }
Пример #8
0
     // $message->to = "Kajan";
     // $message->toEmail = "*****@*****.**";
     // $message->from = "Kajanthan";
     // $message->fromEmail = "*****@*****.**";
     $message->from = "Kajan";
     $message->fromEmail = "*****@*****.**";
     $message->to = "Kajanthan";
     $message->toEmail = "*****@*****.**";
     $message->subject = "Hi this is a test Subject";
     $message->message = "<div><pre>This is some text inside pre tag</pre></div><p>This is a paragraph.</p>";
     $message->cc = "*****@*****.**";
     $message->bcc = "*****@*****.**";
     try {
         // The message needs to be encoded in Base64URL
         $mime = rtrim(strtr(base64_encode($message->formatMessage()), '+/', '-_'), '=');
         $msg = new Google_Service_Gmail_Message();
         $msg->setRaw($mime);
         // $objSentMsg = $service->users_messages->send($userId, $msg);
         // print('Message sent object');
         // print_r($objSentMsg);
     } catch (Exception $e) {
         print $e->getMessage();
     }
 } else {
     if (isset($_POST)) {
         // echo "Number of files to upload: " . ini_get('max_file_uploads') . "\n\r";
         // echo "File upload max size " . ini_get('upload_max_filesize') . "\r\n";
         // echo "File upload max size " . file_upload_max_size() . "\r\n";
         // echo "Post max size " . ini_get('post_max_size') . "\n\r";
         // print_r(isset($_POST));
         if (isset($_POST['type']) && $_POST['type'] == 'sendMail') {
Пример #9
0
     if (isset($_POST['draft'])) {
         $to = $_POST['to'];
         $bcc = $_POST['bcc'];
         $cc = $_POST['cc'];
         $body = $_POST['message'];
         $subject = $_POST['subject'];
         $mime->addTo($to);
         $mime->addBcc($bcc);
         $mime->addCc($cc);
         $mime->setTXTBody($body);
         $mime->setHTMLBody($body);
         $mime->setSubject($subject);
         $message_body = $mime->getMessage();
         $encoded_message = base64url_encode($message_body);
         // Gmail Message Body
         $message = new Google_Service_Gmail_Message();
         $message->setRaw($encoded_message);
         // Gmail Draft
         $draft_body = new Google_Service_Gmail_Draft();
         $draft_body->setMessage($message);
         // Save as Draft
         $draft = $service->users_drafts->create('me', $draft_body);
         if ($draft->getId()) {
             $notice = '<div class="alert alert-success">Draft saved successfully!</div>';
         } else {
             $notice = '<div class="alert alert-danger">Oops...something went wrong, try again later</div>';
         }
     }
 }
 /**
  * Get the list of message ids and filter only messages in inbox under the primary category tab
Пример #10
0
 /**
  * Send an HTML format email.  Any '\n' in the body will be converted to <br>.
  *
  * @param string $to Comma-separated list of email addresses
  * @param string $cc Comma-separated list of email addresses
  * @param string $bcc Comma-separated list of email addresses
  * @param string $subject Message subject
  * @param array $body Array of strings which will form the main body of the email
  * 	                   These will be joined by <br> (a new-line).  To make paragraphs
  * 	                   separate either add a trailing '\n' or '<br>' to a string.
  */
 public function sendEmail($to, $cc, $bcc, $subject, $body)
 {
     global $ini, $verbose;
     $strRawMessage = 'From: ' . $ini['gmail_from'] . "\r\n";
     $strRawMessage .= "To: {$to}\r\n";
     $strRawMessage .= "CC: {$cc}\r\n";
     $strRawMessage .= "BCC: {$bcc}\r\n";
     $strRawMessage .= 'Subject: =?utf-8?B?' . base64_encode($subject) . "?=\r\n";
     $strRawMessage .= "MIME-Version: 1.0\r\n";
     $strRawMessage .= "Content-Type: text/html; charset=utf-8\r\n";
     $strRawMessage .= 'Content-Transfer-Encoding: quoted-printable' . "\r\n\r\n";
     $strRawMessage .= implode('<br>', str_replace(array('\\n', "\n"), '<br>' . "\r\n", $body)) . "\r\n";
     //Users.messages->send - Requires -> Prepare the message in message/rfc822
     // The message needs to be encoded in Base64URL
     $mime = rtrim(strtr(base64_encode($strRawMessage), '+/', '-_'), '=');
     try {
         $msg = new Google_Service_Gmail_Message();
         $msg->setRaw($mime);
         //The special value **me** can be used to indicate the authenticated user.
         $objSentMsg = $this->service->users_messages->send($ini['gmail_username'], $msg);
         if ($verbose > 3) {
             print __FUNCTION__ . '(): Email sent:\\n';
             print_r($objSentMsg);
         }
     } catch (Exception $e) {
         print 'Error: Exception - ' . $e->getMessage() . "\n";
         return FALSE;
     }
     return TRUE;
 }
Пример #11
0
    public function replyMessage()
    {
        $client = $this->getClient();
        $service = new Google_Service_Gmail($client);
        $userId = 'me';
        $thread_id = Input::get('thread_id');
        $assign_to = Input::get('assign_to');
        $employee = Employee::where('employee_identity', $assign_to)->get()->first();
        $employee_name = $employee->name;
        $employee_mobile = $employee->mobile;
        DB::table('create_mail_table')->insert(['thread_id' => $thread_id, 'label' => 'ASSIGN', 'body' => '' . Auth::employee()->get()->name . ' assigned the complaint to ' . $employee_name . '', 'from_mail' => Auth::employee()->get()->name, 'time' => Date("Y-m-d H:i:s")]);
        $ticket_no = TicketSupport::where('thread_id', $thread_id)->get()->first();
        if (!$ticket_no) {
            $ticket_no = $this->generateTicketNo();
            $ticketMail = new TicketSupport();
            $ticketMail->thread_id = $thread_id;
            $ticketMail->ticket_no = $ticket_no;
            $ticketMail->status = 'open';
            $ticketMail->assign_to = $assign_to;
            $ticketMail->save();
        } else {
            $ticket_no = $ticket_no->ticket_no;
        }
        $senderDet = MailSupport::where('thread_id', $thread_id)->orderBy('time', 'ASC')->get()->first();
        $from = $senderDet->to_mail;
        $to = $senderDet->from_mail;
        $subject = $senderDet->subject;
        $content = Input::get('body');
        $body = 'Hi ' . $from . '\\n Ticket No : ' . $ticket_no . '\\n\\n' . $content . '\\n\\nSincerely\\n' . Auth::employee()->get()->name . '\\nOODOO Support team.';
        $message = new Google_Service_Gmail_Message();
        $text = 'From: ' . $from . '
To: ' . $to . '
Subject: Re: ' . $subject . '

' . $body . '';
        $encoded_message = rtrim(strtr(base64_encode($text), '+/', '-_'), '=');
        $message->setRaw($encoded_message);
        $message = $service->users_messages->send($userId, $message);
        $thread = $message->setThreadId($thread_id);
        #var_dump($message); die;
        $senderId = "OODOOS";
        $content = 'compilant ' . 'Ticket No ' . $ticket_no;
        $return = PaymentTransaction::sendsms($employee_mobile, $senderId, $content);
        $inboxmail = new MailSupport();
        $inboxmail->message_id = $message->getId();
        $inboxmail->thread_id = $thread_id;
        $inboxmail->history_id = 1111;
        $inboxmail->label = 'SENT';
        $inboxmail->subject = $subject;
        $inboxmail->from_mail = $from;
        $inboxmail->to_mail = $to;
        $inboxmail->body = $body;
        if (isset($attachment)) {
            $inboxmail->attachment = json_encode($attachment);
        }
        $time = Date("Y-m-d H:i:s");
        $inboxmail->time = $time;
        if ($inboxmail->save()) {
            return Response::json(array('from' => $from, 'body' => $body, 'time' => $time, 'assign_to' => $assign_to));
        } else {
            return Response::json(array('mail' => "false"));
        }
    }
 /**
  *  send gmail
  *
  *  TODO: 請加入附件, 但應該不是在這個 method 擴充
  *
  *  @return boolean
  */
 public static function sendMessage($from, $to, $subject, $body)
 {
     $mail = new \Nette\Mail\Message();
     $mail->setFrom($from)->addTo($to)->setSubject($subject)->setBody($body);
     $messageText = $mail->generateMessage();
     $data = self::_encodeRawData($messageText);
     try {
         $message = new Google_Service_Gmail_Message();
         $message->setRaw($data);
         self::getService()->users_messages->send("me", $message);
     } catch (Exception $e) {
         echo 'Send message error ' . $e->getMessage() . "\n";
         return false;
     }
     return true;
 }
 public function send()
 {
     if (isset($_SESSION['client'])) {
         $util = new Google_Utils();
         require_once dirname(__FILE__) . '/../libraries/PHPMailer/class.phpmailer.php';
         $mail = new PHPMailer();
         $mail->ContentType = 'text/plain';
         $mail->CharSet = "UTF-8";
         $subject = $_POST['subject'];
         $msg = $_POST['body'];
         $from = $_SESSION['user']->email;
         $fname = $_SESSION['user']->name ? $_SESSION['user']->name : $_SESSION['user']->email;
         $mail->From = $from;
         $mail->FromName = $fname;
         $recipients = split(',', $_POST['mail']);
         foreach ($recipients as $value) {
             $mail->AddAddress($value);
         }
         $mail->AddReplyTo($from, $fname);
         $mail->Subject = $subject;
         $mail->Body = $msg;
         $validAttachments = array();
         foreach ($_FILES['attachments']['name'] as $index => $fileName) {
             $filePath = $_FILES['attachments']['tmp_name'][$index];
             if (is_uploaded_file($filePath)) {
                 $attachment = new stdClass();
                 $attachment->fileName = $fileName;
                 $attachment->filePath = $filePath;
                 $validAttachments[] = $attachment;
             }
         }
         foreach ($validAttachments as $attachment) {
             $mail->AddAttachment($attachment->filePath, $attachment->fileName);
         }
         $mail->preSend();
         $mime = $mail->getSentMIMEMessage();
         $message = new Google_Service_Gmail_Message();
         $raw = $util::urlSafeB64Encode($mime);
         $message->setRaw($raw);
         //Creamos una instancia de nuestro "modelo"
         $mailsModel = new MailsModel();
         $aux = $mailsModel->sendMessage($message);
         $this->helper->redirect('/mails/getAll/SENT');
     } else {
         $this->helper->redirect();
     }
 }
 function metodoregistro($gestor)
 {
     $email = Request::post('email');
     $clave = Request::post('clave');
     $claveR = Request::post('claveR');
     $consulta = $gestor->get($email)->getEmail();
     if ($consulta != null) {
         $contenidoParticular = Plantilla::cargarPlantilla("../templates/_mensaje.html");
         $datos = array("mensaje" => "Error. Ya existe un artista para ese email", "ruta" => "../index.php?op=0");
         $contenidoParticular = Plantilla::sustituirDatos($datos, $contenidoParticular);
         $pagina = Plantilla::cargarPlantilla("../templates/_plantilla.1.html");
         $datos = array("contenidoParticular" => $contenidoParticular);
         echo Plantilla::sustituirDatos($datos, $pagina);
     } else {
         if ($clave === $claveR) {
             $nombreArtistico = $email;
             $claveCifrada = sha1($clave . Constant::SEMILLA);
             $artista = new Artista($email, $claveCifrada, $nombreArtistico, 1, 0);
             $gestor->insert($artista);
             $destino = $email;
             $sha1 = sha1($destino . Constant::SEMILLA);
             $origen = '*****@*****.**';
             $asunto = "Validación";
             $mensaje = "Confirme su registro a la galería pulsando el siguiente enlace: " . "https://galeria-mmarjusticia.c9users.io/artista/index.php?op=activar&email={$destino}&sha1={$sha1}";
             require_once '../clases/Google/autoload.php';
             require_once '../clases/class.phpmailer.php';
             //las últimas versiones también vienen con autoload
             $cliente = new Google_Client();
             $cliente->setApplicationName('enviar');
             $cliente->setClientId("270220163093-pe1ci6joub5ai7k0dgtlloukg764pclj.apps.googleusercontent.com");
             $cliente->setClientSecret('U-cIahmOQjJkR4Iyl-A1oL6-');
             $cliente->setRedirectUri('https://galeria-mmarjusticia.c9users.io/oauth/guardar.php');
             $cliente->setScopes('https://www.googleapis.com/auth/gmail.compose');
             $cliente->setAccessToken(file_get_contents('../oauth/token.conf'));
             if ($cliente->getAccessToken()) {
                 $service = new Google_Service_Gmail($cliente);
                 try {
                     $mail = new PHPMailer();
                     $mail->CharSet = "UTF-8";
                     $mail->From = $origen;
                     $mail->FromName = $alias;
                     $mail->AddAddress($destino);
                     $mail->AddReplyTo($origen, $alias);
                     $mail->Subject = $asunto;
                     $mail->Body = $mensaje;
                     $mail->preSend();
                     $mime = $mail->getSentMIMEMessage();
                     $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
                     $mensaje = new Google_Service_Gmail_Message();
                     $mensaje->setRaw($mime);
                     $service->users_messages->send('me', $mensaje);
                     $contenidoParticular = Plantilla::cargarPlantilla("../templates/_mensaje.html");
                     $datos = array("mensaje" => "Para finalizar el registro,verifique su correo electronico y active su cuenta", "ruta" => "../index.php?op=0");
                     $contenidoParticular = Plantilla::sustituirDatos($datos, $contenidoParticular);
                     $pagina = Plantilla::cargarPlantilla("../templates/_plantilla.1.html");
                     $datos = array("contenidoParticular" => $contenidoParticular);
                     echo Plantilla::sustituirDatos($datos, $pagina);
                 } catch (Exception $e) {
                     print $e->getMessage();
                 }
             } else {
                 $contenidoParticular = Plantilla::cargarPlantilla("../templates/_mensaje.html");
                 $datos = array("mensaje" => "Ha ocurrido un error con la conexión, por favor repita el proceso", "ruta" => "../index.php?op=0");
                 $contenidoParticular = Plantilla::sustituirDatos($datos, $contenidoParticular);
                 $pagina = Plantilla::cargarPlantilla("../templates/_plantilla.1.html");
                 $datos = array("contenidoParticular" => $contenidoParticular);
                 echo Plantilla::sustituirDatos($datos, $pagina);
             }
         } else {
             $contenidoParticular = Plantilla::cargarPlantilla("../templates/_mensaje.html");
             $datos = array("mensaje" => "Error. Las contraseñas no coinciden", "ruta" => "../index.php?op=0");
             $contenidoParticular = Plantilla::sustituirDatos($datos, $contenidoParticular);
             $pagina = Plantilla::cargarPlantilla("../templates/_plantilla.1.html");
             $datos = array("contenidoParticular" => $contenidoParticular);
             echo Plantilla::sustituirDatos($datos, $pagina);
         }
     }
 }
Пример #15
0
 static function sendMailCambioEmail($destinatario)
 {
     session_start();
     $secreto = sha1($destinatario . Constant::SEMILLA);
     $origen = "*****@*****.**";
     $alias = "David";
     $destino = $destinatario;
     $asunto = "Cambio de email.";
     $mensaje = "Cambiar el email:   https://gestiondeusuarios-izvdavid2015.c9users.io/php/viewemail.php?correo={$destinatario}&secreto={$secreto}";
     require_once 'MailGoogle/google/autoload.php';
     require_once 'MailGoogle/class.phpmailer.php';
     //las últimas versiones también vienen con autoload
     $cliente = new Google_Client();
     $cliente->setApplicationName(Constant::PRO1);
     $cliente->setClientId(Constant::CID1);
     $cliente->setClientSecret(Constant::CSE1);
     $cliente->setRedirectUri(Constant::URI1);
     $cliente->setScopes('https://www.googleapis.com/auth/gmail.compose');
     $cliente->setAccessToken(file_get_contents('../clases/MailGoogle/token.conf'));
     if ($cliente->getAccessToken()) {
         $service = new Google_Service_Gmail($cliente);
         try {
             $mail = new PHPMailer();
             $mail->CharSet = "UTF-8";
             $mail->From = $origen;
             $mail->FromName = $alias;
             $mail->AddAddress($destino);
             $mail->AddReplyTo($origen, $alias);
             $mail->Subject = $asunto;
             $mail->Body = $mensaje;
             $mail->preSend();
             $mime = $mail->getSentMIMEMessage();
             $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
             $mensaje = new Google_Service_Gmail_Message();
             $mensaje->setRaw($mime);
             $service->users_messages->send('me', $mensaje);
             echo "Correo enviado correctamente.";
         } catch (Exception $e) {
             print $e->getMessage();
             echo "Error en el envio de correo";
         }
     } else {
         echo "No conectado con Gmail.";
     }
 }
Пример #16
0
    echo "<input type='submit' value='Convert to PDF and make drafts!'></form>";
}
if (isset($_POST['report'])) {
    $allowedHeaders = ["Content-Type", "Content-Disposition"];
    foreach ($_POST['report'] as $reportUrl) {
        $to = EMAIL_REPORT_TO;
        $subject = EMAIL_REPORT_SUBJECT;
        $msg = EMAIL_REPORT_BODY . "\n";
        if (isset($_POST['to:' . base64_encode($reportUrl)])) {
            $to = $_POST['to:' . base64_encode($reportUrl)];
        }
        if (isset($_POST['subject:' . base64_encode($reportUrl)])) {
            $subject = $_POST['subject:' . base64_encode($reportUrl)];
        }
        $mail = "To: {$to}\nSubject: {$subject}\n";
        $message = new Google_Service_Gmail_Message();
        $headers = get_headers($reportUrl);
        //        echo '<pre>';
        //        var_dump($headers);
        if ($headers) {
            $im = file_get_contents($reportUrl);
            if ($im === FALSE) {
                echo 'Skipped. Cannot receive file  ' . $reportUrl . '<br>';
                continue;
            }
            $name = base64_encode($reportUrl);
            $mail .= "Content-Type: multipart/mixed; boundary=\"{$name}\" \n";
            $mail .= "--{$name}\n";
            $mail .= "Content-Type: text/plain; charset=UTF-8\n\n";
            $mail .= $msg;
            $mail .= "--{$name}\n";
Пример #17
0
//las últimas versiones también vienen con autoload
$cliente = new Google_Client();
$cliente->setApplicationName('ProyectoEnviarCorreo');
$cliente->setClientId('304670743598-f6luuojm498kah8fnuqarr0mmcrg918n.apps.googleusercontent.com');
$cliente->setClientSecret('ep2o5eER7ELsUJvptEEkonTk');
$cliente->setRedirectUri('https://pruebacorreo-juanmanuelolalla.c9users.io/oauth/guardar.php');
$cliente->setScopes('https://www.googleapis.com/auth/gmail.compose');
$cliente->setAccessToken(file_get_contents('token.conf'));
if ($cliente->getAccessToken()) {
    $service = new Google_Service_Gmail($cliente);
    try {
        $mail = new PHPMailer();
        $mail->CharSet = "UTF-8";
        $mail->From = $origen;
        $mail->FromName = $alias;
        $mail->AddAddress($destino);
        $mail->AddReplyTo($origen, $alias);
        $mail->Subject = $asunto;
        $mail->Body = $mensaje;
        $mail->preSend();
        $mime = $mail->getSentMIMEMessage();
        $mime = rtrim(strtr(base64_encode($mime), '+/', '-_'), '=');
        $mensaje = new Google_Service_Gmail_Message();
        $mensaje->setRaw($mime);
        $service->users_messages->send('me', $mensaje);
        echo "correo enviado correctamente";
    } catch (Exception $e) {
        echo "Algun error";
        print $e->getMessage();
    }
}
Пример #18
0
 /**
  * onCreateNewQuestion
  *
  * @param QuestionAnswerEvent $event
  *
  * @return void
  */
 public function onCreateNewQuestion(QuestionAnswerEvent $event)
 {
     $container = $this->getContainer();
     $question = $event->getQuestion();
     $token = $container->get('security.context')->getToken();
     $service = $container->get('cekurte_google_api.gmail');
     if ($service->getClient()->isAccessTokenExpired()) {
         $service->getClient()->refreshToken($token->getRefreshToken());
     }
     try {
         $message = \Swift_Message::newInstance();
         $message->addTo($container->getParameter('cekurte_zcpe_google_group_mail'))->addFrom($this->getUser()->getEmail())->setSubject($this->getSubject($question))->setBody($this->getTemplateBody($question), 'text/plain')->setEncoder(\Swift_Encoding::getBase64Encoding())->setCharset('utf-8');
         $gmailMessage = new \Google_Service_Gmail_Message();
         $gmailMessage->setRaw(base64_encode($message->toString()));
         $service->users_messages->send('me', $gmailMessage);
         $container->get('session')->getFlashBag()->add('message', array('type' => 'success', 'message' => $container->get('translator')->trans('The email has been sent successfully.')));
         $question->setEmailHasSent(true);
         $em = $this->getContainer()->get('doctrine')->getManager();
         $em->persist($question);
         $em->flush();
     } catch (\Google_Service_Exception $e) {
         $container->get('session')->getFlashBag()->add('message', array('type' => 'error', 'message' => $e->getMessage()));
     }
 }