Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Código do loadLibrary
- public function loadLibrary($lib){
- if(file_exists('libs/' . $lib . '.php')){
- include 'libs/' . $lib . '.php';
- }
- }
- //Código do Autoload
- <?php
- session_start();
- require 'config.php';
- spl_autoload_register(function ($class){
- if(strpos($class, 'Controller') > -1){
- if(file_exists('controllers/' . $class . '.php')){
- require_once 'controllers/' . $class . '.php';
- }
- }else if(file_exists('models/' . $class . '.php')){
- require_once 'models/' . $class . '.php';
- }else{
- require_once 'core/' . $class . '.php';
- }
- });
- $core = new Core();
- $core->run();
- ?>
- // Código do controller em que preciso usar o phpMailer
- <?php
- class contatoController extends controller
- {
- public function faleConosco(){
- if(isset($_POST['nome']) && !empty($_POST['nome']) &&
- isset($_POST['email']) && !empty($_POST['email']) &&
- isset($_POST['assunto']) && !empty($_POST['assunto']) &&
- isset($_POST['mensagem']) && !empty($_POST['mensagem'])
- ){
- $nome = addslashes($_POST['nome']);
- $email = addslashes($_POST['email']);
- $assunto = addslashes($_POST['assunto']);
- $mensagem = addslashes($_POST['mensagem']);
- $this->loadLibrary('phpmailer/PHPMailerAutoload');
- $mail = new PHPMailer();
- echo "<script>alert('Estou entrando aqui');</script>";
- /*$mail->isSMTP();
- $mail->Host = 'aqui vai o servidor'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'aqui vai o email'; // SMTP username
- $mail->Password = 'aqui vai a senha'; // SMTP password
- $mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = aqui vai a porta; // TCP port to connect to
- $mail->setFrom($email, 'Usuário Plataforma EAD');
- $mail->addAddress('contato@claudiojunior.tk'); // Name is optional
- $mail->isHTML(false); // Set email format to HTML
- $mail->Subject = $assunto;
- $mail->Body = $mensagem;
- $mail->AltBody = $mensagem;
- if(!$mail->send()) {
- echo "<script>alert('Message could not be sent')</script>";
- echo "<script>alert('Mailer Error: " . $mail->ErrorInfo . "')</script>";
- } else {
- echo "<script>alert('Message has been sent')</script>";
- }
- */
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement