MLM - Can I get email notification from new subscribers?

sclark

New Member
I use MLM script with MBM to handle all subscriptions via remote lists. Is there any way to also get notified via email when someone new subscribes? Want to be able to send a special one-time "welcome" email to just those new people who have signed up.
 

stanbusk

Administrator
Staff member
You already get notified actually. You should receive a message when someone subscribe or unsubscribe. Make sure $admin_notifications is set to 1 in the mlm_settings.php file.
 

sclark

New Member
Not getting subscribe notification...

The $admin_notifications IS set to "1". I am getting the unsubscribe notifications, but not the subscribe notifications. I removed the double opt-in code since it was not desired so now I'm wondering if something else was deleted too. Any suggestions on how to fix this? I currently have a loose workaround with some extra php code at the top of the actual page the form is on but I'm pretty sure even though it works, it's probably not the best way to do it. Help please? Here's the extra php code I put on the page the form is on:

<?php if(isset($_GET["submit"])){
$exception_fields=array("submit");
$to="[email protected]";
$from=$_GET['email'];
$subject="Joy At Work New Subscriber Notification";
$message_body="";
$br="\n";
foreach($_POST as $fieldName => $value){
if(!in_array($fieldName,$exception_fields)){
$fieldName=str_replace("_"," ",$fieldName);
$message_body=$message_body.$fieldName.": ".$value.$br;
}
}
$message=$message_body;
$headers="From:".$from;
if(mail($to, stripslashes($subject), stripslashes($message),$headers)){
if($success_page!=""){
header("Location:".$success_page);
}
}
}
?>
 

stanbusk

Administrator
Staff member
Putting code into the form is not the best approach (imo) because perhaps the address will not finally be subscribed successfully because of an error.

In mlm.php. Look for the 'SendSubscriptionMessage()' function. At the end you should see:
Code:
	if ( $admin_notifications == 1 ) {
		$subject = str_replace( "[EMAIL]", $email, str_replace( "[LISTS]", $listfordisplay, $kTxt_emailsubject_esl[$lang] ) );
		$message = $subject . ".";
		$headers = "From: \"$admin_name_full\" <$admin_address>";	
		SendMessage( $admin_address, $subject, $message, $headers, $encoding );
	}
This is the code that send the subscription notification to you.
 

sclark

New Member
I figured that probably wasn't the best way... I checked the mlm.php file. Here's the code... it seems to be fine. Not exactly the same as yours should still work, right? Does it have anything to do with changing the opt-in info to false?

// Send a confirmation message to the subscriber
function SendSubscriptionMessage() {
global $msg_confirmation, $admin_address, $path_to_script, $cmd, $list, $listfordisplay;
global $admin_name_full, $admin_webAddress, $script_name, $script_version;
global $firstname, $lastname, $company, $email, $admin_notifications;

$url = $path_to_script . "?cmd=unsubscribe&list=" . urlencode( $list ) . "&email=" . $email;

$listfordisplay = formatlistnames( $list );

$subject = "Your subscription confirmation";
$message = $msg_confirmation;
$message = str_replace( "
  • ", $listfordisplay, $message );
    $message = str_replace( "", $email, $message );
    $message = str_replace( "[UNSUBSCRIBE_URL]", $url, $message );
    $message = str_replace( "[SIGNATURE]", "$admin_name_full\n$admin_webAddress\n$script_name $script_version", $message );
    $headers = "From: $admin_address";

    SendMessage( $email, $subject, $message, $headers, $encoding );

    if ( $admin_notifications == 1 ) {
    $subject = "$email has subscribed to $listfordisplay";
    $message = $subject . ".";
    $headers = "From: $admin_address";
    SendMessage( $admin_address, $subject, $message, $headers, $encoding );
    }
 

stanbusk

Administrator
Staff member
Try to activate and deactivate opt-in. I don't remember if it has an effect on this. Right now I am working on mlm v2. About the code, it looks correct to me however both the sender and receiver of the message is the same address. Is it possible your server doesn't like this?
 

sclark

New Member
where are you seeing this?

Where at in the code are you seeing the sender and receiver being the same?
 

stanbusk

Administrator
Staff member
$headers = "From: $admin_address";
SendMessage( $admin_address, $subject, $message, $headers, $encoding );
$admin_address = $headers

Try to replace $headers with something else like:
Code:
$headers = "From: [email protected]";
replacing mydomain.mytld with your own domain.
 

sclark

New Member
doesn't seem to change anything

I made the change to the $header, but it still isn't sending notification emails for subscribing, only for unsubscribing. Any advice on how to fix this? As far as you know, even when the double opt-in option is turned off, should the subscribe and unsubscribe notifications to the administrator still work?
 

stanbusk

Administrator
Staff member
Weird, the code is correct and works perfect for me here. Perhaps your server is trashing the message because he believes it is spam. The double opt-in option has absolutely nothing to do with this. Only $admin_notifications activate or deactivate this feature. If $admin_notifications = 1 notifications are sent. Try to modify the text of the notification.
 
Top