Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use PHPMailerPHPMailerPHPMailer;
- use PHPMailerPHPMailerException;
- require 'assets/PHPMailer/src/Exception.php';
- require 'assets/PHPMailer/src/PHPMailer.php';
- require 'assets/PHPMailer/src/SMTP.php';
- $mail = new PHPMailer(true); // Passing `true` enables exceptions
- try {
- //Server settings
- $mail->SMTPDebug = 0; // Enable verbose debug output
- $mail->isSMTP(); // Set mailer to use SMTP
- $mail->Host = 'test'; // Specify main and backup SMTP servers
- $mail->SMTPAuth = true; // Enable SMTP authentication
- $mail->Username = 'test'; // SMTP username
- $mail->Password = 'test'; // SMTP password
- $mail->SMTPSecure = 'ssl'; // Enable TLS encryption, `ssl` also accepted
- $mail->Port = 465; // TCP port to connect to
- //Recipients
- $mail->setFrom('test');
- $mail->addAddress('test'); // Add a recipient
- $mail->addReplyTo('test', 'Information');
- $mail->addCC('cc@example.com');
- $mail->addBCC('bcc@example.com');
- //Content
- $mail->isHTML(true); // Set email format to HTML
- $mail->Subject = 'Here is the subject';
- $mail->Body = 'This is the HTML message body <b>in bold!</b>';
- $mail->send();
- echo 'Message has been sent';
- } catch (Exception $e) {
- echo 'Message could not be sent.';
- echo 'Mailer Error: ' . $mail->ErrorInfo;
- }
- ?>
- <div class="block">
- <h2>Send message</h2>
- <form>
- <div class="form-group">
- <input type="text" name="mail" class="form-control" placeholder="Email Address">
- </div>
- <div class="form-group">
- <input type="text" name="subject" class="form-control" placeholder="Subject">
- </div>
- <div class="form-group">
- <textarea class="form-control" name="text" rows="3" placeholder="Your Message"></textarea>
- <button class="btn btn-default" type="submit" >Send Message</button>
- </div>
- </form>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement