Quantcast
Channel: Tópicos
Viewing all articles
Browse latest Browse all 14700

Erro com PHPMailer

$
0
0
Boa noite,

Estava a criar um formulário em HTML que iria comunicar com o meu código PHP e são os seguintes:

HTML:

<!DOCTYPE html>
<html>

<head>

<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>Inscrição de Sócio CUP</title>

<link rel="stylesheet" href="cup.css">
<link rel="stylesheet" href="cup-socio.css">

</head>


<header>
<h1>Inscrição de Sócio CUP</h1>
</header>

<body>
<div class="main-content">

<!-- You only need this form and the form-basic.css -->

<form class="form-basic" method="post" action="send-email.php">

<div class="form-row">
<label for="name">
<span>Nome</span>
<input type="text" name="name" id="name">
</label>
</div>

<div class="form-row">
<label for="email">
<span>E-mail</span>
<input type="email" name="email" id="email">
</label>
</div>

<div class="form-row">
<label for="id">
<span>B.I./C.C.</span>
<input type="text" name="id" id="id">
</label>
</div>

<div class="form-row">
<label for="sexo">
<span>Sexo</span>
<select name="sexo" id="sexo">
<option>Masculino</option>
<option>Feminino</option>
</select>
</label>
</div>

<div class="form-row">
<label for="data_nascimento">
<span>Data de Nascimento</span>
<input type="date" name="data_nascimento" id="data_nascimento">
</label>
</div>

<div class="form-row">
<label for="morada">
<span>Morada</span>
<textarea name="morada" id="morada"></textarea>
</label>
</div>

<div class="form-row">
<label for="localidade">
<span>Código Postal</span>
<input type="text" name="localidade" maxlength="8" id="postal">
</label>
</div>

<div class="form-row">
<label for="localidade">
<span>Localidade</span>
<input type="text" name="localidade" id="localidade">
</label>
</div>

<div class="form-row">
<label for="telefone">
<span>Telefone</span>
<input type="text" name="telefone" maxlength="9" id="telefone">
</label>
</div>

<div class="form-row">
<label for="telemovel">
<span>Telemóvel</span>
<input type="text" name="telemovel" maxlength="9" id="telemovel">
</label>
</div>


<div class="form-row">
<button type="submit" name="submit" id="submit" value="Send">Submeter</button>
</div>

</form>

</div>

</body>

</html>

PHP:

<?php

require_once 'phpmailer/class.smtp.php';
require_once 'phpmailer/class.phpmailer.php';
$smtp = 'smtp';
$user = 'email';
$pass = 'Pass';
$mail = new PHPMailer();
$mail->CharSet = "UTF-8";
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = $smtp;
$mail->Port = 25;
$mail->Username = $user;
$mail->Password = $pass;
$mail->SetFrom('mail', 'nome');
$mail->Subject = "Nova inscrição de sócio";

function getGetVariable($varName) {

return !empty($_GET[$varName]) ? $_GET[$varName] : '';
}

$body = '<table>';
/* name */
$body .= '  <tr>';
$body .= '   <td><b>Nome:</b></td>';
$body .= '   <td>' . getGetVariable('name') . '</td>';
$body .= '  </tr>';
/* email */
$body .= '  <tr>';
$body .= '   <td><b>Email:</b></td>';
$body .= '   <td>' . getGetVariable('email') . '</td>';
$body .= '  </tr>';
/* id */
$body .= '  <tr>';
$body .= '   <td><b>B.I./C.C.:</b></td>';
$body .= '   <td>' . getGetVariable('id') . '</td>';
$body .= '  </tr>';
/* sexo */
$body .= '  <tr>';
$body .= '   <td><b>Sexo:</b></td>';
$body .= '   <td>' . getGetVariable('sexo') . '</td>';
$body .= '  </tr>';
/* data_nascimento */
$body .= '  <tr>';
$body .= '   <td><b>Data de Nascimento:</b></td>';
$body .= ' <td>' . date('d-m-Y', strtotime(getGetVariable('data_nascimento'))) . '</td>';
$body .= '  </tr>';
/* morada */
$body .= '  <tr>';
$body .= '   <td><b>Morada:</b></td>';
$body .= '   <td>' . nl2br(getGetVariable('morada')) . '</td>';
$body .= '  </tr>';
/* postal */
$body .= '  <tr>';
$body .= '   <td><b>Código Postal:</b></td>';
$body .= '   <td>' . getGetVariable('postal') . '</td>';
$body .= '  </tr>';
/* localidade */
$body .= '  <tr>';
$body .= '   <td><b>Localidade:</b></td>';
$body .= '   <td>' . getGetVariable('localidade') . '</td>';
$body .= '  </tr>';
/* telefone */
$body .= '  <tr>';
$body .= '   <td><b>Localidade:</b></td>';
$body .= '   <td>' . getGetVariable('telefone') . '</td>';
$body .= '  </tr>';
/* telemovel */
$body .= '  <tr>';
$body .= '   <td><b>Localidade:</b></td>';
$body .= '   <td>' . getGetVariable('telemovel') . '</td>';
$body .= '  </tr>';
/* Close table */
$body .= '</table>';
$mail->MsgHTML($body);
$mail->AddAddress('mail', 'nome');
if ($mail->Send()) {
} else {
}



Alguma coisa neste código está mail pois consigo receber os e-mails mas vêm sem informação! O que se passa?

Caso vejam algum erro agradecia que me informassem o mais rápido possível e como resolve-lo!

Aguardo resposta,
mikeysantana

Viewing all articles
Browse latest Browse all 14700