I've got this newsletter for my website. It runs of my own mailserver, running Mercury.
To simplify subscribing and unsubscribing, I've built a PHP script to handle sending those commands to the server. The maillist for the newsletter is setup to send confirmations out to anyone who wish to subscribe, therefor all messages coming into the server must produce response.
The first version of the script, did send the commands to the server, and the server correctly directed it to the listserver, but no response was made, so clearly something was off ... so today I've tried correctifying the script to make the server accept the commands ... Now I get a response, but not what I'm looking for.
Mercury's maillist server requires the subscription command to be:
SUBSCRIBE listname name EXIT
So I've pieced together this script (some parts are a couple of months old, so it's a bit clumsy still), note that I've only included the relevant parts, there are loads of lines commented out and other stuff controlling menus and formats that I've not included:
// pull fields from form query $to = "[EMAIL PROTECTED]"; $name = $HTTP_POST_VARS['name']; $address = $HTTP_POST_VARS['address']; $listname = $HTTP_POST_VARS['listname']; $action = strtoupper($HTTP_POST_VARS['action']);
// build headers $from = "\"$name\" <$address>\r\n"; $message = $action." ".$listname." ".$name."\r\n"; $message .= "EXIT\r\n";
$headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n"; $headers .= "From: ".$from."\r\n"; $headers .= "Reply-to: ".$from."\r\n";
// check action state $phase = $_POST['phase'];
if(! isset($phase)) { $phase = 1; }
// verify email format if ($phase > 1) { // note: validateEmailFormat is included in line 3!! if (! validateEmailFormat($address)) { $phase = 1; $error = 'address'; } else { $phase = 3; } }
<!-- big html part snipped for purpose of message length on PHP list -->
<?php
if ($phase == 3) {
if (mail($to,"",$message,$headers)) {
if ($action == "SUBSCRIBE") {
?>
<span class="bldtxt">Your subscription to the <?php echo($listname); ?> mailing list has been
accepted and delivered to the list server.</span><br>
<span class="txt">You will shortly receive a confirmation request
at <?php echo($address); ?> to which you must reply in order to complete the subscription.
Details on how to do this are included in the message you receive.</span>
<?php
}
elseif ($action == "UNSUBSCRIBE") {
?>
<span class="bldtxt">Your unsubscription from the <?php echo($listname); ?> mailing list has
been accepted and delivered to the list server.</span><br>
<span class="txt">You will be unsubscribed immediately and will receive confirmation on this as
soon as the list server has finished processing your request. Any mail sent to you prior to the
receipt of the unsub request will still be delivered.</span>
<?php
}
}
else {
?>
<span class="hdline2">An error occured!</span><br>
<span class="txt">Sorry, your message could not be delivered.</span>
<?php
}
} // end of phase send message
* after all this comes all the form parts. These are all just a big bunch of HTML and PHP if-lines mixed together to refill out the fields when some field is not filled correctly by the user.
When using my yahoo account as test-target for this script, I get this in return from my Mercury server:
== quote from error message == The mail server has encountered errors processing your request:
* Unrecognized command "Reply-to:".
Please correct and resubmit your request(s). If you need further assistance, either use the Mail Server HELP command, or else contact the postmaster or administrator of this system. == end quote ==
After editing the to field to direct the message to myself rather than the server, this is how it looks in Eudora:
Received: from spooler by metalbunny.net (Mercury/32 v3.32); 11 Jun 03 23:22:44 +0100
X-Envelope-To: <[EMAIL PROTECTED]>
Return-path: <[EMAIL PROTECTED]>
Received: from rage-j (127.0.0.1) by mailboss.metalbunny.net (Mercury/32 v3.32) ID MG00028D;
11 Jun 03 23:22:38 +0100
Date: Wed, 11 Jun 2003 23:22:38 +0100
Subject:
To: [EMAIL PROTECTED]
MIME-Version: 1.0
Content-type: text/plain; charset=iso-8859-1
From: "DeltaPower" <[EMAIL PROTECTED]>
Reply-to: "DeltaPower" <[EMAIL PROTECTED]>
SUBSCRIBE stayintouch DeltaPower EXIT
Obviously, there's an extra line between the From and the Reply-to field, which is why Mercury thinks the reply-to is in the body. Mercury is made (or setup, not sure which) so that it will stop processing when it finds something it doesn't understand. I use the reply to field just as a safety measure ...
Any ideas y'all ???
TIA
Rene -- Rene Brehmer aka Metalbunny
http://metalbunny.net/ References, tools, and other useful stuff...
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php