Advertisement
Guest User

Untitled

a guest
Feb 8th, 2018
431
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1.     // ENVIO DE E-MAIL UTILIZANDO A API DO ELASTICEMAIL
  2.  
  3.     public function enviaEmail()
  4.     {
  5.         $email = $_POST['email'];
  6.         $assunto = $_POST['assunto'];
  7.         $msg = "";
  8.         $msg .= '<h3>' . $assunto .'</h3>';
  9.         $msg .= '<p><b>Nome:</b> ' . $_POST['nome'] . '<br>';
  10.         $msg .= '<b>Email:</b> ' . $_POST['email'] . '<br>';
  11.         $msg .= '<b>Mensagem:</b> ' . $_POST['mensagem'] . '<br>';
  12.         $msg .= '<b>Data:</b> ' . date('d/m/Y H:s') . '</p><br>';
  13.  
  14. //        API elasticemail
  15.         $url = 'https://api.elasticemail.com/v2/email/send';
  16.         try{
  17.             $post = array('from' => 'email@hotmail.com',
  18.                 'fromName' => 'Orlando Almeida',
  19.                 'apikey' => '$apielastic',
  20.                 'charset' => 'utf-8',
  21.                 'sender' => 'email@hotmail.com',
  22.                 'senderName' => 'Orlando Almeida',
  23.                 'replyTo' => "$email",
  24.                 'subject' => "Contato do site Nome do site - $assunto",
  25.                 'to' => "orlando.ealmeida@gmail.com;$email", // array de e-mails
  26.                 'bodyHtml' => "$msg",
  27.                 'isTransactional' => false);
  28.  
  29.             $ch = curl_init();
  30.             curl_setopt_array($ch, array(
  31.                 CURLOPT_URL => $url,
  32.                 CURLOPT_POST => true,
  33.                 CURLOPT_POSTFIELDS => $post,
  34.                 CURLOPT_RETURNTRANSFER => true,
  35.                 CURLOPT_HEADER => false,
  36.                 CURLOPT_SSL_VERIFYPEER => false
  37.             ));
  38.  
  39.             $result=curl_exec ($ch);
  40.             curl_close ($ch);
  41.  
  42.             echo $result;
  43.         }
  44.         catch(Exception $ex){
  45.             echo $ex->getMessage();
  46.         }
  47.         $this->session->set_flashdata('email', TRUE);
  48.         redirect('');
  49.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement