Merge pull request #9 from TimStallard/email-smtp
Re-wrote email system to use an external SMTP server
This commit is contained in:
commit
f15468aeec
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
node_modules
|
node_modules
|
||||||
out
|
out
|
||||||
|
src/files/contactsubmit/conf.php
|
||||||
|
@ -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
|
||||||
|
@ -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(),
|
||||||
|
@ -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);
|
|
3966
src/files/contactsubmit/class.phpmailer.php
Normal file
3966
src/files/contactsubmit/class.phpmailer.php
Normal file
File diff suppressed because it is too large
Load Diff
1214
src/files/contactsubmit/class.smtp.php
Normal file
1214
src/files/contactsubmit/class.smtp.php
Normal file
File diff suppressed because it is too large
Load Diff
9
src/files/contactsubmit/conf.example.php
Normal file
9
src/files/contactsubmit/conf.example.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
$mailconf = [
|
||||||
|
"host" => "",
|
||||||
|
"username" => "",
|
||||||
|
"password" => "",
|
||||||
|
"security" => "tls",
|
||||||
|
"port" => 587,
|
||||||
|
"address" => ""
|
||||||
|
]
|
30
src/files/contactsubmit/index.php
Normal file
30
src/files/contactsubmit/index.php
Normal 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();
|
Loading…
Reference in New Issue
Block a user