Page 1 of 1

mass mailing

Posted: Mon Jul 23, 2012 8:42 am
by umamaheswararao
how can i restrict the automatic mailing to all users who subscribed the email alerts.my question is when new user is subscribing the automatic mail is sent to all users who are already in mysql db..how can i stop to mailing to already registered users

Re: mass mailing

Posted: Mon Jul 23, 2012 9:00 am
by Helx
Check if the user has clicked the submit button, then set up a mail(); thingy.
if(isset($_POST["submit"])){

    // Do the actual subscription first

    $to = $_POST["email"];
    $headers = 'From: webmaster@example.com' . "\r\n" .
    $subject = "You have subscribed to us!";
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();
    $message = "You're now subscribed to our newsletter!";

    mail($to, $subject, $message, $headers);
}
Depending on what you're doing, you may want to send the latest newsletter to the new subscriber. Simply change the $message variable to whatever you want. Maybe a database thing.

You'll want to look more deeply into checking if the user is already subscribed before sending the 'success' email, and maybe add a touch more security to everything. Like maybe a captcha or anti-robot question.

Oh, and you may want to change the subject... I'm pretty sure that'll end up in spam XD

Re: mass mailing

Posted: Tue Jul 24, 2012 12:55 am
by jacek
umamaheswararao wrote:how can i restrict the automatic mailing to all users who subscribed the email alerts.my question is when new user is subscribing the automatic mail is sent to all users who are already in mysql db..how can i stop to mailing to already registered users
Depends how you know they have registered ? If there name is in another table check for that, if there is a column that gets set to 1 check for that. No way to answer fully unless you give a bit more information. ;)

Re: mass mailing

Posted: Tue Jul 24, 2012 4:34 am
by Helx
umamaheswararao wrote:to all users who subscribed the email alerts.
Wow.. I completely read that wrong :/

Re: mass mailing

Posted: Wed Jul 25, 2012 11:19 pm
by jacek
abcedea wrote:Wow.. I completely read that wrong :/
Yep :lol: