Replace PHP mail() functions with PHPMailer script
This commit is contained in:
parent
3b47088207
commit
8905de70ba
56
admin.php
56
admin.php
|
@ -1,5 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('prefs.php');
|
require_once('prefs.php');
|
||||||
|
require_once __DIR__.'/contactform/vendor/autoload.php';
|
||||||
|
require_once __DIR__.'/contactform/config.php';
|
||||||
|
|
||||||
|
$mail = new \PHPMailer\PHPMailer\PHPMailer(true);
|
||||||
|
$mail->setLanguage(CONTACTFORM_LANGUAGE);
|
||||||
|
$mail->SMTPDebug = CONTACTFORM_PHPMAILER_DEBUG_LEVEL;
|
||||||
|
$mail->isSMTP();
|
||||||
|
$mail->Host = CONTACTFORM_SMTP_HOSTNAME;
|
||||||
|
$mail->SMTPAuth = true;
|
||||||
|
$mail->Username = CONTACTFORM_SMTP_USERNAME;
|
||||||
|
$mail->Password = CONTACTFORM_SMTP_PASSWORD;
|
||||||
|
$mail->SMTPSecure = CONTACTFORM_SMTP_ENCRYPTION;
|
||||||
|
$mail->Port = CONTACTFORM_SMTP_PORT;
|
||||||
|
$mail->CharSet = CONTACTFORM_MAIL_CHARSET;
|
||||||
|
$mail->Encoding = CONTACTFORM_MAIL_ENCODING;
|
||||||
|
|
||||||
if (isset($_COOKIE['bellabuffs'])) {
|
if (isset($_COOKIE['bellabuffs'])) {
|
||||||
if ($_COOKIE['bellabuffs'] == md5($admin_name.$admin_pass.$secret)) {
|
if ($_COOKIE['bellabuffs'] == md5($admin_name.$admin_pass.$secret)) {
|
||||||
if (isset($_GET['ap'])) { $page = $_GET['ap']; } else { $page = ""; }
|
if (isset($_GET['ap'])) { $page = $_GET['ap']; } else { $page = ""; }
|
||||||
|
@ -106,19 +122,21 @@ if (isset($_COOKIE['bellabuffs'])) {
|
||||||
while ($i < $apprAmount) {
|
while ($i < $apprAmount) {
|
||||||
list($name,$email,$dispemail,$url,$country,$fave) = preg_split("/,(?! )/",$approved[$i]);
|
list($name,$email,$dispemail,$url,$country,$fave) = preg_split("/,(?! )/",$approved[$i]);
|
||||||
|
|
||||||
$subject = "You have been approved at $title";
|
// Recipients
|
||||||
|
$mail->setFrom($admin_email, $title);
|
||||||
|
$mail->addAddress(fixEmail($email), $name);
|
||||||
|
$mail->addReplyTo($admin_email);
|
||||||
|
|
||||||
$message = $approvalMsg;
|
$mail->Subject = "You have been approved at $title";
|
||||||
$message .= "Name: {$name} \r\n";
|
|
||||||
$message .= "Email: " . fixEmail($email) . " \r\n";
|
|
||||||
$message .= "URL: {$url} \r\n";
|
|
||||||
$message .= "Country: {$country} \r\n";
|
|
||||||
if (isset($favefield) && $favefield == "yes") $message .= strip_tags($favetext) . ": {$fave} \r\n";
|
|
||||||
|
|
||||||
if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) $headers = "From: $admin_email \n";
|
$mail->Body = $approvalMsg;
|
||||||
else $headers = "From: $title <$admin_email> \n";
|
$mail->Body .= "Name: {$name} \r\n";
|
||||||
|
$mail->Body .= "Email: " . fixEmail($email) . " \r\n";
|
||||||
|
$mail->Body .= "URL: {$url} \r\n";
|
||||||
|
$mail->Body .= "Country: {$country} \r\n";
|
||||||
|
if (isset($favefield) && $favefield == "yes") $mail->Body .= strip_tags($favetext) . ": {$fave} \r\n";
|
||||||
|
|
||||||
mail(fixEmail($email),$subject,$message,$headers);
|
$mail->send();
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
@ -920,20 +938,14 @@ if (isset($_COOKIE['bellabuffs'])) {
|
||||||
$clean[$key] = stripslashes(trim($val));
|
$clean[$key] = stripslashes(trim($val));
|
||||||
}
|
}
|
||||||
|
|
||||||
$subject = "E-mail from the $FLsubject fanlisting";
|
// Recipients
|
||||||
|
$mail->setFrom($admin_email, $title);
|
||||||
|
$mail->addAddress($clean['to']);
|
||||||
|
$mail->addReplyTo($admin_email);
|
||||||
|
|
||||||
if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
|
$mail->Subject = "E-mail from the $FLsubject fanlisting";
|
||||||
$clean['to'] = str_replace('>', '', $clean['to']);
|
|
||||||
$clean['to'] = str_replace('<', '', $clean['to']);
|
|
||||||
|
|
||||||
$headers = "From: $admin_email \n";
|
if ($mail->send()) {
|
||||||
$headers .= "Reply-To: $admin_email";
|
|
||||||
} else {
|
|
||||||
$headers = "From: $title <$admin_email> \n";
|
|
||||||
$headers .= "Reply-To: <$admin_email>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mail($clean['to'],$subject,$clean['message'],$headers)) {
|
|
||||||
echo "<p>E-mail sent!</p>";
|
echo "<p>E-mail sent!</p>";
|
||||||
echo "<p><a href='admin.php'>Back to admin panel?</a></p>";
|
echo "<p><a href='admin.php'>Back to admin panel?</a></p>";
|
||||||
} else {
|
} else {
|
||||||
|
|
46
contact.php
46
contact.php
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('prefs.php');
|
require_once('prefs.php');
|
||||||
|
require_once __DIR__.'/contactform/vendor/autoload.php';
|
||||||
|
require_once __DIR__.'/contactform/config.php';
|
||||||
|
|
||||||
$error_msg = null;
|
$error_msg = null;
|
||||||
$result = null;
|
$result = null;
|
||||||
|
@ -49,26 +51,38 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||||
$error_msg .= "Invalid website url.\r\n";
|
$error_msg .= "Invalid website url.\r\n";
|
||||||
|
|
||||||
if ($error_msg == NULL && $points <= $maxPoints) {
|
if ($error_msg == NULL && $points <= $maxPoints) {
|
||||||
$subject = "Contact form submission from ". $title;
|
$mail = new \PHPMailer\PHPMailer\PHPMailer(true);
|
||||||
|
|
||||||
$message = "You received this e-mail message through your fanlisting: \n\n";
|
// Server settings
|
||||||
|
$mail->setLanguage(CONTACTFORM_LANGUAGE);
|
||||||
|
$mail->SMTPDebug = CONTACTFORM_PHPMAILER_DEBUG_LEVEL;
|
||||||
|
$mail->isSMTP();
|
||||||
|
$mail->Host = CONTACTFORM_SMTP_HOSTNAME;
|
||||||
|
$mail->SMTPAuth = true;
|
||||||
|
$mail->Username = CONTACTFORM_SMTP_USERNAME;
|
||||||
|
$mail->Password = CONTACTFORM_SMTP_PASSWORD;
|
||||||
|
$mail->SMTPSecure = CONTACTFORM_SMTP_ENCRYPTION;
|
||||||
|
$mail->Port = CONTACTFORM_SMTP_PORT;
|
||||||
|
$mail->CharSet = CONTACTFORM_MAIL_CHARSET;
|
||||||
|
$mail->Encoding = CONTACTFORM_MAIL_ENCODING;
|
||||||
|
|
||||||
|
// Recipients
|
||||||
|
$mail->setFrom($admin_email, $title.' Contact Form');
|
||||||
|
$mail->addAddress($admin_email, $admin_name);
|
||||||
|
$mail->addReplyTo($_POST['email'], $_POST['name']);
|
||||||
|
|
||||||
|
$mail->Subject = "Contact form submission from ". $title;
|
||||||
|
|
||||||
|
$mail->Body = "You received this e-mail message through your fanlisting: \n\n";
|
||||||
foreach ($_POST as $key => $val) {
|
foreach ($_POST as $key => $val) {
|
||||||
$message .= ucwords($key) . ": " . cleanUp($val) . "\r\n";
|
$mail->Body .= ucwords($key) . ": " . cleanUp($val) . "\r\n";
|
||||||
}
|
}
|
||||||
$message .= "\r\n";
|
$mail->Body .= "\r\n";
|
||||||
$message .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
|
$mail->Body .= 'IP: '.$_SERVER['REMOTE_ADDR']."\r\n";
|
||||||
$message .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
|
$mail->Body .= 'Browser: '.$_SERVER['HTTP_USER_AGENT']."\r\n";
|
||||||
$message .= 'Points: '.$points;
|
$mail->Body .= 'Points: '.$points;
|
||||||
|
|
||||||
if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
|
if ($mail->send()) {
|
||||||
$headers = "From: {$admin_email}\n";
|
|
||||||
$headers .= "Reply-To: {$_POST['email']}";
|
|
||||||
} else {
|
|
||||||
$headers = "From: {$title} <{$admin_email}>\n";
|
|
||||||
$headers .= "Reply-To: {$_POST['email']}";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mail($admin_email,$subject,$message,$headers)) {
|
|
||||||
$result = 'Your mail was successfully sent.';
|
$result = 'Your mail was successfully sent.';
|
||||||
$disable = true;
|
$disable = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
83
join.php
83
join.php
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
$show_form = true;
|
$show_form = true;
|
||||||
$error_msg = NULL;
|
$error_msg = NULL;
|
||||||
|
require_once __DIR__.'/contactform/vendor/autoload.php';
|
||||||
|
require_once __DIR__.'/contactform/config.php';
|
||||||
|
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
require_once('prefs.php');
|
require_once('prefs.php');
|
||||||
|
@ -98,55 +100,66 @@ if (isset($_POST['submit'])) {
|
||||||
$clean['email'] = breakEmail(strtolower($clean['email']));
|
$clean['email'] = breakEmail(strtolower($clean['email']));
|
||||||
|
|
||||||
// send off some emails
|
// send off some emails
|
||||||
|
$mail = new \PHPMailer\PHPMailer\PHPMailer(true);
|
||||||
|
// Server settings
|
||||||
|
$mail->setLanguage(CONTACTFORM_LANGUAGE);
|
||||||
|
$mail->SMTPDebug = CONTACTFORM_PHPMAILER_DEBUG_LEVEL;
|
||||||
|
$mail->isSMTP();
|
||||||
|
$mail->Host = CONTACTFORM_SMTP_HOSTNAME;
|
||||||
|
$mail->SMTPAuth = true;
|
||||||
|
$mail->Username = CONTACTFORM_SMTP_USERNAME;
|
||||||
|
$mail->Password = CONTACTFORM_SMTP_PASSWORD;
|
||||||
|
$mail->SMTPSecure = CONTACTFORM_SMTP_ENCRYPTION;
|
||||||
|
$mail->Port = CONTACTFORM_SMTP_PORT;
|
||||||
|
$mail->CharSet = CONTACTFORM_MAIL_CHARSET;
|
||||||
|
$mail->Encoding = CONTACTFORM_MAIL_ENCODING;
|
||||||
|
|
||||||
if ($emailnewbies == "yes") {
|
if ($emailnewbies == "yes") {
|
||||||
$subject = "Thank you for joining $title";
|
// Recipients
|
||||||
|
$mail->setFrom($admin_email, $title);
|
||||||
|
$mail->addAddress(fixEmail($clean['email']), $clean['name']);
|
||||||
|
$mail->addReplyTo($admin_email);
|
||||||
|
|
||||||
$message = $thanksjoinMsg;
|
// Content
|
||||||
$message .= "Name: {$clean['name']} \n";
|
$mail->Subject = "Thank you for joining $title";
|
||||||
$message .= "Email: " . fixEmail($clean['email']) . " \n";
|
$mail->Body = $thanksjoinMsg . "\n\n";
|
||||||
$message .= "URL: {$clean['url']} \n";
|
$mail->Body .= "== Your Details == \n";
|
||||||
$message .= "Country: {$clean['country']} \n";
|
$mail->Body .= "Name: {$clean['name']} \n";
|
||||||
|
$mail->Body .= "Email: " . fixEmail($clean['email']) . " \n";
|
||||||
|
$mail->Body .= "URL: {$clean['url']} \n";
|
||||||
|
$mail->Body .= "Country: {$clean['country']} \n";
|
||||||
if (isset($favefield) && $favefield == "yes") {
|
if (isset($favefield) && $favefield == "yes") {
|
||||||
$message .= "$favetext: {$clean['fave']} \n";
|
$mail->Body .= "$favetext: {$clean['fave']} \n";
|
||||||
}
|
}
|
||||||
$message .= "Comments: {$clean['comments']} \n\n";
|
$mail->Body .= "Comments: {$clean['comments']} \n\n";
|
||||||
|
|
||||||
if (strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
|
$mail->send();
|
||||||
$headers = "From: $admin_email \n";
|
|
||||||
$headers .= "Reply-To: $admin_email";
|
|
||||||
} else {
|
|
||||||
$headers = "From: $title <$admin_email> \n";
|
|
||||||
$headers .= "Reply-To: <$admin_email>";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mail(fixEmail($clean['email']),$subject,$message,$headers);
|
|
||||||
}
|
|
||||||
if ($emailadmin == "yes") {
|
if ($emailadmin == "yes") {
|
||||||
$subject = "New member at $title";
|
// Remove previous recipients
|
||||||
|
$mail->ClearAllRecipients();
|
||||||
|
|
||||||
$message = "There's a new member at your $FLsubject fanlisting with the following details: \n\n";
|
$mail->setFrom($admin_email, $title);
|
||||||
|
$mail->addAddress($admin_email, $admin_name);
|
||||||
|
|
||||||
$message .= "Name: {$clean['name']} \n";
|
$mail->Subject = "New member at $title";
|
||||||
$message .= "Email: " . fixEmail($clean['email']) . " \n";
|
|
||||||
$message .= "URL: {$clean['url']} \n";
|
$mail->Body = "There's a new member at your $FLsubject fanlisting with the following details: \n\n";
|
||||||
$message .= "Country: {$clean['country']} \n";
|
|
||||||
|
$mail->Body .= "Name: {$clean['name']} \n";
|
||||||
|
$mail->Body .= "Email: " . fixEmail($clean['email']) . " \n";
|
||||||
|
$mail->Body .= "URL: {$clean['url']} \n";
|
||||||
|
$mail->Body .= "Country: {$clean['country']} \n";
|
||||||
if (isset($favefield) && $favefield == "yes") {
|
if (isset($favefield) && $favefield == "yes") {
|
||||||
$message .= "$favetext: {$clean['fave']} \n";
|
$mail->Body .= "$favetext: {$clean['fave']} \n";
|
||||||
}
|
}
|
||||||
$message .= "Comments: {$clean['comments']} \n";
|
$mail->Body .= "Comments: {$clean['comments']} \n";
|
||||||
$message .= "IP: {$_SERVER['REMOTE_ADDR']} \n\n";
|
$mail->Body .= "IP: {$_SERVER['REMOTE_ADDR']} \n\n";
|
||||||
|
|
||||||
$message .= "Manage members: {$FLurl}/admin.php?ap=manage_members&s=newbies";
|
$mail->Body .= "Manage members: {$FLurl}/admin.php?ap=manage_members&s=newbies";
|
||||||
|
|
||||||
if (!strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
|
$mail->send();
|
||||||
$headers = "From: $admin_email \n";
|
|
||||||
$headers .= "Reply-To: " . fixEmail($clean['email']) . "";
|
|
||||||
} else {
|
|
||||||
$headers = "From: $title <$admin_email> \n";
|
|
||||||
$headers .= "Reply-To: <" . fixEmail($clean['email']) . ">";
|
|
||||||
}
|
|
||||||
|
|
||||||
mail($admin_email,$subject,$message,$headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// add the member to the newbies txt file
|
// add the member to the newbies txt file
|
||||||
|
|
53
update.php
53
update.php
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
$show_form = true;
|
$show_form = true;
|
||||||
$error_msg = NULL;
|
$error_msg = NULL;
|
||||||
|
require_once __DIR__.'/contactform/vendor/autoload.php';
|
||||||
|
require_once __DIR__.'/contactform/config.php';
|
||||||
|
|
||||||
if (isset($_POST['submit'])) {
|
if (isset($_POST['submit'])) {
|
||||||
require_once('prefs.php');
|
require_once('prefs.php');
|
||||||
|
@ -89,32 +91,41 @@ if (isset($_POST['submit'])) {
|
||||||
if ($error_msg == NULL) {
|
if ($error_msg == NULL) {
|
||||||
$show_form = false;
|
$show_form = false;
|
||||||
|
|
||||||
$subject = "Update member at $title";
|
$mail = new \PHPMailer\PHPMailer\PHPMailer(true);
|
||||||
|
// Server settings
|
||||||
|
$mail->setLanguage(CONTACTFORM_LANGUAGE);
|
||||||
|
$mail->SMTPDebug = CONTACTFORM_PHPMAILER_DEBUG_LEVEL;
|
||||||
|
$mail->isSMTP();
|
||||||
|
$mail->Host = CONTACTFORM_SMTP_HOSTNAME;
|
||||||
|
$mail->SMTPAuth = true;
|
||||||
|
$mail->Username = CONTACTFORM_SMTP_USERNAME;
|
||||||
|
$mail->Password = CONTACTFORM_SMTP_PASSWORD;
|
||||||
|
$mail->SMTPSecure = CONTACTFORM_SMTP_ENCRYPTION;
|
||||||
|
$mail->Port = CONTACTFORM_SMTP_PORT;
|
||||||
|
$mail->CharSet = CONTACTFORM_MAIL_CHARSET;
|
||||||
|
$mail->Encoding = CONTACTFORM_MAIL_ENCODING;
|
||||||
|
|
||||||
$message = "A member at your $FLsubject fanlisting wants updating with following details: \n\n";
|
// Recipients
|
||||||
|
$mail->setFrom($admin_email, $title);
|
||||||
|
$mail->addAddress($admin_email, $admin_name);
|
||||||
|
|
||||||
$message .= "Name: {$clean['name']} \n";
|
$mail->Subject = "Update member at $title";
|
||||||
$message .= "Email: ".strtolower($clean['email'])." \n";
|
|
||||||
$message .= "New Email: {$clean['newemail']} \n";
|
|
||||||
$message .= "New URL: {$clean['newurl']} \n";
|
|
||||||
$message .= "Country: {$clean['country']} \n";
|
|
||||||
$message .= "Comments: {$clean['comments']} \n";
|
|
||||||
$message .= "IP: {$_SERVER['REMOTE_ADDR']} \n\n";
|
|
||||||
|
|
||||||
$message .= "Manage members: {$FLurl}/admin.php";
|
$mail->Body = "A member at your $FLsubject fanlisting wants updating with following details: \n\n";
|
||||||
|
$mail->Body .= "Name: {$clean['name']} \n";
|
||||||
|
$mail->Body .= "Email: ".strtolower($clean['email'])." \n";
|
||||||
|
$mail->Body .= "New Email: {$clean['newemail']} \n";
|
||||||
|
$mail->Body .= "New URL: {$clean['newurl']} \n";
|
||||||
|
$mail->Body .= "Country: {$clean['country']} \n";
|
||||||
|
$mail->Body .= "Comments: {$clean['comments']} \n";
|
||||||
|
$mail->Body .= "IP: {$_SERVER['REMOTE_ADDR']} \n\n";
|
||||||
|
|
||||||
if (!strstr($_SERVER['SERVER_SOFTWARE'], "Win")) {
|
$mail->Body .= "Manage members: {$FLurl}/admin.php";
|
||||||
$headers = "From: $admin_email \n";
|
|
||||||
$headers .= "Reply-To: $clean[email]";
|
if ($mail->send()) {
|
||||||
|
echo "<h1>Update Sent!</h1><p>Your updated information has been sent to the fanlisting owner.</p>";
|
||||||
} else {
|
} else {
|
||||||
$headers = "From: $title <$admin_email> \n";
|
echo "<h1>Oops!</h1><p>Your updated information could not be sent this time, please contact the fanlisting owner.</p>";
|
||||||
$headers .= "Reply-To: <$clean[email]>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mail($admin_email,$subject,$message,$headers)) {
|
|
||||||
echo "<h1>Update Sent!</h1> \n <p>Your updated information has been sent.</p>";
|
|
||||||
} else {
|
|
||||||
echo "<h1>Oops!</h1> \n <p>Your updated information could not be sent this time, please contact the fanlisting owner.</p>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue