Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $msg = "";
- use PHPMailer\PHPMailer\PHPMailer;
- include_once "PHPMailer/PHPMailer.php";
- include_once "PHPMailer/Exception.php";
- include_once "PHPMailer/SMTP.php";
- if (isset($_POST['submit'])) {
- $subject = $_POST['subject'];
- $email = $_POST['email'];
- $message = $_POST['message'];
- $mail = new PHPMailer();
- //if we want to send via SMTP
- $mail->Host = "smtp.mail.com";
- $mail->isSMTP();
- $mail->SMTPAuth = true;
- $mail->Username = "mail@mail.com";
- $mail->Password = "12345";
- $mail->SMTPSecure = "tls"; //TLS
- $mail->Port = 587; //587
- $mail->addAddress('mail@mail.com');
- $mail->setFrom('mail@mail.com', 'Guest');
- $mail->Subject = $subject;
- $mail->isHTML(true);
- $mail->Body = $message;
- if ($mail->send())
- $msg = "Your email has been sent, thank you!";
- else
- //$msg = "Please try again!";
- echo $mail->ErrorInfo;
- }
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport"
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
- <meta http-equiv="X-UA-Compatible" content="ie=edge">
- <title>Contact Form</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
- </head>
- <body>
- <div class="container" style="margin-top: 100px">
- <div class="row justify-content-center">
- <div class="col-md-6 col-md-offset-3" align="center">
- <br><br>
- <?php if ($msg != "") echo "$msg<br><br>"; ?>
- <form method="post" action="sendemail.php">
- <input class="form-control" name="subject" placeholder="Subject..."><br>
- <input class="form-control" name="email" type="email" placeholder="Email..."><br>
- <textarea placeholder="Message..." class="form-control" name="message"></textarea><br>
- <input class="btn btn-primary" name="submit" type="submit" value="Send Email">
- </form>
- </div>
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement