I'm having trouble sending messages through my hosted UOL Host website. They require sending through authenticated SMTP. I'm using PHP Mailer. The form worked but stopped working.
contact.php
<form name="sentMessage" id="contactForm" novalidate>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Nome</label>
<input disabled type="text" class="form-control" placeholder="Nome" id="name" required data-validation-required-message="Por favor, digite seu nome.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Empresa</label>
<input disabled type="text" class="form-control" placeholder="Empresa" id="empresa">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Email</label>
<input disabled type="email" class="form-control" placeholder="Email" id="email" required data-validation-required-message="Por favor, digite seu email.">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>DDD + Telefone</label>
<input disabled type="tel" class="form-control" placeholder="DDD + Telefone" id="phone">
<p class="help-block text-danger"></p>
</div>
</div>
<div class="row control-group">
<div class="form-group col-xs-12 floating-label-form-group controls">
<label>Mensagem</label>
<textarea disabled rows="5" class="form-control" placeholder="Mensagem" id="message" required data-validation-required-message="Por favor, escreva sua mensagem."></textarea>
<p class="help-block text-danger"></p>
</div>
</div>
<br>
<div id="success"></div>
<div class="row">
<div class="form-group col-xs-12">
<button disabled type="submit" class="btn btn-success btn-lg pull-right" name="enviar">Enviar</button>
<button type="reset" class="btn btn-link btn-sm pull-left">Limpar formulário</button>
</div>
</div>
</form>
contact_me.php
<?php
$name = $_POST['name'];
$empresa = $_POST['empresa'];
$email_address = $_POST['email'];
$phone = $_POST['phone'];
$message = $_POST['message'];
$user = '[email protected]';
$destino = '[email protected]';
require 'PHPMailerAutoload.php';
$mail = new PHPMailer();
$mail->setLanguage('pt');
// Define os dados do servidor e tipo de conexão
$mail->IsSMTP();
$mail->Host = 'smtp.avss.com.br'; // Endereço do servidor SMTP
$mail->SMTPAuth = true; // Usa autenticação SMTP? (opcional)
$mail->Username = $user; // Usuário do servidor SMTP
$mail->Password = '***********'; // Senha do servidor SMTP
$mail->Port = 587;
$mail->setFrom($user, 'Fale Conosco AVSS'); // // Define o remetente
$mail->addReplyTo($email_address); // Define email para resposta
$mail->addAddress($user); // Define os destinatário(s)
//$mail->addAddress($destino);
//$mail->addBCC('');
$mail->IsHTML(true); // Define que o e-mail será enviado como HTML
$mail->CharSet = 'utf-8';
$mail->WorWrap = 70;
$mail->Subject = 'Contato via site'; // Assunto da mensagem
$mail->Body =
"<body style='background: #FFF; padding: 0; margin: 0;'>
<div style='position: relative; width: 800px; height: auto; padding: 0; margin: 0;'>
<br />
<span style='line-height: 20px; font-family: Arial; font-size: 13px; color: #444;'><b>NOME: </b></span>
<span style='font-family: Arial; font-size: 13px; color: #0076a3;'>" . $name . "</span><br />
<span style='line-height: 20px; font-family: Arial; font-size: 13px; color: #444;'><b>EMPRESA: </b></span>
<span style='font-family: Arial; font-size: 13px; color: #0076a3;'>" . $empresa . "</span><br />
<span style='line-height: 20px; font-family: Arial; font-size: 13px; color: #444;'><b>EMAIL: </b></span>
<span style='font-family: Arial; font-size: 13px; color: #0076a3;'>" . $email_address . "</span><br />
<span style='line-height: 20px; font-family: Arial; font-size: 13px; color: #444;'><b>TELEFONE: </b></span>
<span style='font-family: Arial; font-size: 13px; color: #0076a3;'>" . $phone . "</span><br /><br />
<span style='line-height: 20px; font-family: Arial; font-size: 13px; color: #444;'><b>MENSAGEM: </b></span>
<span style='font-family: Arial; font-size: 13px; color: #0076a3;'>" . $message . "</span><br />
</div>
</body>";
// Envia o e-mail
if(!$mail->Send()){
$mensagemRetorno = 'Erro ao enviar e-mail: '. print($mail->ErrorInfo);
} else {
$mensagemRetorno = 'E-mail enviado com sucesso!';
}
} {}
return true;
?>