Advertisement
Guest User

Untitled

a guest
Oct 4th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. <form class="coluna coluna-3" method="POST" action="email.php">
  2. Nome:<br/>
  3. <input type="text" name="nome" maxlength="50"/><br/>
  4. e-mail:<br/>
  5. <input type="text" name="email" maxlength="50"/><br/>
  6. Assunto:<br/>
  7. <input type="text" name="assunto" maxlength="50"/><br/>
  8. Mensagem:<br/>
  9. <textarea name="mensagem" rows="10" cols="50" maxlength="500"></textarea>
  10. <br/>
  11. <input type="submit" value="Enviar"/>
  12. </form>
  13.  
  14. // Inclui o arquivo class.phpmailer.php localizado na pasta phpmailer
  15. require_once('../phpmailer/class.phpmailer.php');//já tentei sem ../ também
  16. // Inicia a classe PHPMailer
  17. $mail = new PHPMailer();
  18. // Define os dados do servidor e tipo de conexão
  19. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  20. $mail->IsSMTP(true); // Define que a mensagem será SMTP
  21. $mail->Host = "smtp.gmail.com"; // Endereço do servidor SMTP
  22. $mail->Port = 587;
  23. $mail->SMTPAuth = true; // Usa autenticação SMTP? (opcional)
  24. $mail->SMTPSecure = 'ssl';
  25. $mail->Username = 'eu@gmail.com'; // Usuário do servidor SMTP
  26. $mail->Password = 'minhasenha'; // Senha do servidor SMTP
  27. // Define o remetente
  28. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  29. $mail->From = "eu@gmail.com"; // Seu e-mail
  30. $mail->FromName = "Joãozinho"; // Seu nome
  31. // Define os destinatário(s)
  32. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  33. $mail->AddAddress('eu@gmail.com', 'Fulano da Silva');
  34. // Define os dados técnicos da Mensagem
  35. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  36. $mail->IsHTML(true); // Define que o e-mail será enviado como HTML
  37. // Define a mensagem (Texto e Assunto)
  38. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  39. $mail->Subject = "Mensagem Teste"; // Assunto da mensagem
  40. $mail->Body = "Este é o corpo da mensagem de teste, em <b>HTML</b>! :)";
  41. $mail->AltBody = "Este é o corpo da mensagem de teste, em Texto Plano! rn :)";
  42. // Define os anexos (opcional)
  43. // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  44. //$mail->AddAttachment("c:/temp/documento.pdf", "novo_nome.pdf"); // Insere um anexo
  45. // Envia o e-mail
  46. $enviado = $mail->Send();
  47. // Limpa os destinatários e os anexos
  48. $mail->ClearAllRecipients();
  49. $mail->ClearAttachments();
  50. // Exibe uma mensagem de resultado
  51. if ($enviado) {
  52. echo "E-mail enviado com sucesso!";
  53. }
  54. else {
  55. echo "Não foi possível enviar o e-mail.";
  56. echo "<b>Informações do erro:</b> " . $mail->ErrorInfo;
  57. }
  58.  
  59. require('phpmailer/PHPMailerAutoload.php');
  60.  
  61. // 1 = Erros e mensagens
  62. // 2 = Apenas mensagens
  63. $mail->SMTPDebug = 1;
  64.  
  65. De: $mail->SMTPSecure = 'ssl';
  66.  
  67. Para: $mail->SMTPSecure = '**tls**';
  68.  
  69. <?php
  70. require_once 'swift/lib/swift_required.php';
  71.  
  72. $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
  73. ->setUsername('GMAIL_USERNAME')
  74. ->setPassword('GMAIL_PASSWORD');
  75.  
  76. $mailer = Swift_Mailer::newInstance($transport);
  77.  
  78. $message = Swift_Message::newInstance('Test Subject')
  79. ->setFrom(array('abc@example.com' => 'ABC'))
  80. ->setTo(array('xyz@test.com'))
  81. ->setBody('This is a test mail.');
  82.  
  83. $result = $mailer->send($message);
  84. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement