Merge pull request #9 from TimStallard/email-smtp

Re-wrote email system to use an external SMTP server
This commit is contained in:
Tim Stallard 2016-10-30 22:22:56 +00:00 committed by GitHub
commit f15468aeec
8 changed files with 5222 additions and 11 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
node_modules node_modules
out out
src/files/contactsubmit/conf.php

View File

@ -11,5 +11,6 @@ This is the code behind timstallard.me.uk, which is built using Docpad.
### To compile the site for deployment: ### To compile the site for deployment:
1. Run `docpad clean` to remove dev files 1. Run `docpad clean` to remove dev files
2. Run `docpad generate --env=static` 2. Run `docpad generate --env=static`
3. Copy contactsubmit/conf.example.php to contactsubmit/conf.php, and update options as required
© Tim Stallard 2016 © Tim Stallard 2016

View File

@ -40,7 +40,7 @@ order: 1
<script> <script>
$("#contactform").submit(function(e){ $("#contactform").submit(function(e){
$.post( $.post(
"/contactsubmit.php", "/contactsubmit/",
{ {
name: $("input[name='name']").val(), name: $("input[name='name']").val(),
subject: $("input[name='subject']").val(), subject: $("input[name='subject']").val(),

View File

@ -1,10 +0,0 @@
<?php
$message = "";
foreach($_POST as $item => $contents){
$message .= $item . ": " . $contents . "\n";
}
mail("contact@timstallard.me.uk", "Website Email", $message);
print_r($_POST);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,9 @@
<?php
$mailconf = [
"host" => "",
"username" => "",
"password" => "",
"security" => "tls",
"port" => 587,
"address" => ""
]

View File

@ -0,0 +1,30 @@
<?php
require "./class.smtp.php";
require "./class.phpmailer.php";
require "./conf.php";
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPAuth = true;
$mail->Host = $mailconf["host"];
$mail->Username = $mailconf["username"];
$mail->Password = $mailconf["password"];
$mail->SMTPSecure = $mailconf["security"];
$mail->Port = $mailconf["port"];
$message = "";
foreach($_POST as $item => $contents){
$message .= $item . ": " . $contents . "\n";
}
$mail->setFrom($mailconf["address"], "Website Contact");
$mail->addAddress($mailconf["address"], "Website Contact");
$mail->addReplyTo($_POST["contact"], $_POST["name"]);
$mail->Subject = "Website Contact Page Message";
$mail->Body = $message;
$mail->send();