Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $txtName = "Bruno";
- $txtAs = "As";
- $txtEmail = "Text mail";
- $txtMensage = "Text Body";
- $mensageBody = "<b>Name:</b> ".$txtName." <br><b>As:</b> ".$txtAs."<br><b>Message:</b> ".$txtMensage;
- require 'phpmailer/PHPMailerAutoload.php';
- require 'phpmailer/class.smtp.php';
- function smtpmailer($to, $from, $nameDes, $as, $body) {
- global $error;
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->SMTPDebug = 2;
- $mail->SMTPSecure = 'tls';
- $mail->Host = 'smtp.gmail.com';
- $mail->Port = 587;
- $mail->SMTPAuth = true;
- $mail->SMTPSecure = true;
- $mail->Username = 'mail@gmail.com';
- $mail->Password = 'pass';
- $mail->SetFrom($from, $nameDes);
- $mail->Subject = $as;
- $mail->Body = $body;
- $mail->AddAddress($to);
- $mail->IsHTML(true);
- if(!$mail->Send()) {
- $error = "<font color='red'><b>Mail error: </b></font>".$mail->ErrorInfo;
- return false;
- } else {
- $error = "<font color='blue'><b>Mensagem enviada com Sucesso!</b></font>";
- return true;
- }
- }
- if (smtpmailer('mail@gmail.com', 'mail@gmail.com', $txtName, $txtAs, $mensageBody)) {
- Header("location: sucesso.php");
- }
- if (!empty($error)) echo $error;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement