Form-based ezmlm list sign ups using PHP, not working

skypanther

Exalted Code Master!
On one of my sites, I use the ezmlm mailing list. I wanted a web page sign-up for the list. I've done this before at other hosts. But it's not working here. Here, ezmlm is picking up the address I have configured in my php.ini file and using it as the address to be signed up.

Here's the code I'm using to compose and send the message:

$to = '[email protected]';
$body = 'subscribe';
$headers = "Return-Path: " . $_POST['emailAddress'] . "\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
$headers .= "X-Priority: 1\n";
$headers .= "X-MSMail-Priority: High\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: " . $_POST['emailAddress'] . "\n";

mail($to, $subject, $body, $headers);

Here's what shows up in the email header:

Return-Path: <[email protected]>
Received: (qmail 3647 invoked by uid 399); 3 Nov 2005 02:40:49 -0000
Received: from unknown (HELO customer-1298) (200.10.100.200)
by mail3.m****here.biz with SMTP; 3 Nov 2005 02:40:49 -0000
Date: Wed, 02 Nov 2005 21:43:59 -0500
Subject:
To: [email protected]
Return-Path: [email protected]
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-1
X-Priority: 1
X-MSMail-Priority: High
X-Mailer: php
From: [email protected]

Rather than trying to sign up [email protected], ezmlm thinks the person at [email protected] is trying to sign up. It's picking up the first Return-Path (which you can see I've tried to override with my own version, but it shows up later in the headers).

Obviously, I've faked up addresses here. The [email protected] is configured in the php.ini file on my site (this site is running on a Windows box here). The listmemberwannabe.com fake address is what I enter into the text box on my sign up form.

Can I somehow configure ezmlm to read the From address rather than Return-Path address?

Or, someone have some other code suggestions?

Thanks,
Tim

PS - I thought I had this same sort of code running on one of the Linux boxes here. But I just tested and it's not working either. Darn, I wonder how many signups I've missed there...
 
In case anyone cares, not getting an answer on how to change the configuraiton, I changed my code instead.

1) Add the Return-Path email address (the one in your php.ini) as a moderator to your email list.

2) Use code like this to send the subscribe/unsubscribe message to the list as if you were performing remote administration from a "foreign" email account:
PHP:
$from = $_POST['sAddr'];
if($_POST['action'] == 'join') {
	$to='listname-subscribe-'.str_replace('@','=',$from).'@domain.com';
	$body = 'subscribe';
	$redir = 'index.php?message=subscribed';
	if($from != "" && $to != "") {
		$headers .= "MIME-Version: 1.0\n";
		$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
		$headers .= "X-Priority: 1\n";
		$headers .= "X-MSMail-Priority: High\n";
		$headers .= "X-Mailer: php\n";
		$headers .= "From: " . $from . "\n";
		
		mail($to, $subject, $body, $headers);
	}
} elseif($_POST['action'] == 'leave') {
	$to='listname-unsubscribe-'.str_replace('@','=',$from).'@domain.com';
	$body = 'unsubscribe';
	$redir = 'index.php?message=unsubscribed';
	if($from != "" && $to != "") {
		$headers .= "MIME-Version: 1.0\n";
		$headers .= "Content-type: text/plain; charset=iso-8859-1\n";
		$headers .= "X-Priority: 1\n";
		$headers .= "X-MSMail-Priority: High\n";
		$headers .= "X-Mailer: php\n";
		$headers .= "From: " . $from . "\n";
		
		mail($to, $subject, $body, $headers);
	}
} else {
	// your error handling code goes here
}

This assumes you have a signup form with a text box named sAddr (aka, "subscriber's address") for the user's email address and a radio button set named 'action' with two options: join and leave. I redirect to a "thanks" page that is customized to the users action, too. Hence the $redir variable in my code above.

Tim
 
Back
Top