com web/master: Switch mailing list subscription to use smtp directly to php-smtp2: entry/subscribe.php
| From: | Rasmus Lerdorf | Date: | Sun, 12 Nov 2017 06:33:37 +0000 |
| Subject: | com web/master: Switch mailing list subscription to use smtp directly to php-smtp2: entry/subscribe.php | ||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-26561@lists.php.net to get a copy of this message | ||
Commit: 292fee9646247f8c624e4fff2b728812508477d5
Author: Rasmus Lerdorf <rasmus@lerdorf.com> Sat, 11 Nov 2017 22:33:37 -0800
Parents: 34090570cabc4bde677cff5aeffb4580019c4b82
Branches: master
Link: http://git.php.net/?p=web/master.git;a=commitdiff;h=292fee9646247f8c624e4fff2b728812508477d5
Log:
Switch mailing list subscription to use smtp directly to php-smtp2
Changed paths:
M entry/subscribe.php
Diff:
diff --git a/entry/subscribe.php b/entry/subscribe.php
index 3681b2c..b0e19db 100644
--- a/entry/subscribe.php
+++ b/entry/subscribe.php
@@ -1,5 +1,12 @@
<?php
+use PHPMailer\PHPMailer\PHPMailer;
+use PHPMailer\PHPMailer\Exception;
+
+require 'PHPMailer/src/Exception.php';
+require 'PHPMailer/src/PHPMailer.php';
+require 'PHPMailer/src/SMTP.php';
+
include "email-validation.inc";
// Check parameters
@@ -27,16 +34,18 @@ if (!preg_match("!^[a-z0-9-]+$!", $_POST['maillist'])) {
// Generate needed subpart of email address
$sub = str_replace("@", "=", $_POST['email']);
-// Try to send the subscription mail
-$mail_sent = mail(
- "{$_POST['maillist']}-{$_POST['request']}-$sub@lists.php.net",
- "PHP Mailing List Website Subscription",
- "This was a request generated from the form at {$_POST['referer']} by
{$_POST['remoteip']}.",
- "From: {$_POST['email']}\r\n",
- "-fnoreply@php.net"
-);
+date_default_timezone_set('Etc/UTC');
+$mail = new PHPMailer;
+$mail->isSMTP();
+$mail->SMTPDebug = 2;
+$mail->Host = 'php-smtp2.php.net';
+$mail->Port = 25;
+$mail->setFrom($_POST['email']);
+$mail->addAddress("{$_POST['maillist']}-{$_POST['request']}-$sub@lists.php.net");
+$mail->Subject = "PHP Mailing List Website Subscription";
+$mail->Body = "This was a request generated from the form at {$_POST['referer']}
by {$_POST['remoteip']}";
+$mail_sent = $mail->send();
-// Check if we sent mail
if (!$mail_sent) {
- die("Unable to send mail");
+ die("Mailer Error: " . $mail->ErrorInfo);
}