[add-on] Birthday Mailings

3rd party code for phpList

[add-on] Birthday Mailings

Postby jtbjustin » 12:51am, Sun 24 Apr, 2005

Hello,
I run a scrapbooking store and I have my newsletter for my costumers. When they subscribe I also take down their birthday. I think it would be an excellent idea if on peoples' birthdays the system could send them an e-mail wishing them a happy birthday and perhaps offering them something like special discount. Unfortunately I know no PHP what so ever, but I was wondering if any one has a script like this?

Thank You Very Much
-Justin
jtbjustin
phpLister
 
Posts: 7
Joined: 9:15pm, Thu 21 Apr, 2005

Postby OrangeUFO » 12:53am, Fri 26 May, 2006

I am really interested in this as well. Doesn anyone have a solution or possibly recommend a program that does this???
OrangeUFO
PL Nut
 
Posts: 27
Joined: 12:51am, Fri 26 May, 2006

Postby skydiver » 6:47pm, Thu 17 Aug, 2006

Ditto here... I capture B-Day Month and Date as well as Anniversary Month and Date and woulod like to do the same.
skydiver
phpLister
 
Posts: 13
Joined: 2:22pm, Tue 23 May, 2006

Postby skydiver » 3:10pm, Tue 17 Oct, 2006

I still haven't heard of a solution for this yet either. Still looking for a solution. I suppose I could run a backend query form a script file and then send an email that way but I am looking for an easier way, especially for users of the email engine that have no access to to the backend.
skydiver
phpLister
 
Posts: 13
Joined: 2:22pm, Tue 23 May, 2006

Postby robpet » 1:06am, Sat 11 Nov, 2006

I too, wanted this feature. It is vital to me for a client. Since there seemed to be nothing, I decided to do it myself.

So with a BASIC understanding of PHP (but I'm learning), I wrote something. It's really a hack, but it works.

With the code (below), you have to define your html page, which is your birthday wish (and drop it in the same directory or build the path to it), as well as some email address stuff and of course your database names, etc. I have CAPITALIZED the stuff that should be changed.

I have tried this out, and it will send the HMTL message, and display it also as a text email for those that can't get HTML.

There are a couple of things to keep in mind... This is not personalized...so if anyone out there has a thought as to how to personalize the greeting, I would really appreciate it.

Second, you actually have to run this page in a browser to make it work. I would suspect you can run it in a Cron Job, but I don't know how to do that...so I'd appreciate some instructions if anyone has some...

Third, this was built reading a MySQL database on a Linux server with a PHPList install of 2.10.3.

Lastly, this does not produce a report. I think it would be great if someone can make it create a report , and have that emailed to the administrator. I could do that, but I have some other things to get to. At least this will work for the time being.

Code: Select all

<html>
<head>
<title>Birthday Test</title>
<meta>

<?

$dbh=mysql_connect ("localhost", "DATABASENAME", "PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("DATABASE");//not sure why this is here again :(
$sql = 'SELECT * FROM `phplist_user_user_attribute`';
$result=mysql_query($sql);
$num=mysql_numrows($result);
mysql_close();

   $dbh=mysql_connect ("localhost", "DATABASENAME", "PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
   mysql_select_db ("DATABASENAME");
   $sql = 'SELECT * FROM `phplist_user_user`';
   $emails=mysql_query($sql);
   $total=mysql_numrows($emails);
   mysql_close();


echo "<b><center>Database Output</center></b><br><br>";
$today = mktime(0, 0, 0, date("m"), date("d"), date("y"));

$i=0;
$count = 0;
$success  = 0;

while ($i < $num) {
   $id=mysql_result($result,$i,"attributeid");
   $test=mysql_result($result,$i,"userid");
   $birthday=mysql_result($result,$i,"value");
   $month = substr($birthday, 5, 2);
   $day = substr($birthday, 8, 2);

   if ($id == 1){
      $firstName = $birthday;
   }
   if ($id == 11 && $month == date("m") && $day == date("d")) {
      $j=0;
      while ($j <total>
</head>
<body>
</body>
</html>



Credits go to the people who put up PHP instructions on the net with examples, and anyone else who's code I stole.

And now the only other thing that I need, that I can't find, that I guess I have to do myself, is to get Wordpress to read the PHPList database to allow people to make comments.

Members of PHPList should be able to post comments on Wordpress without having to register there too. Any thoughts?

I have found nothing on Google for this, so if someone has anything, I would appreciate it.

Otherwise, enjoy your birthday function!


rob
robpet
PL Nut
 
Posts: 23
Joined: 3:48am, Wed 25 Oct, 2006

Postby robpet » 1:10am, Sat 11 Nov, 2006

Hmmm, when I posted this, the bottom part got cut off...weird.

So here's the "second half". Lose the while J loop above, and everything after it.

Replace it with this:

Code: Select all

      while ($j <total>
</head>
<body>
</body>
</html>




Then you should have it.

Sorry for the trouble.



rob
robpet
PL Nut
 
Posts: 23
Joined: 3:48am, Wed 25 Oct, 2006

Postby robpet » 1:15am, Sat 11 Nov, 2006

Okay, so something doesn't like the second half of the code.

Egg on my face.

Email me at rbpettigrew at gmail dot com if you want the whole code. Be warned, I don't check it that often, so post here when you email me, so I know to go in and reply.

Sorry for the hassle....



rob
robpet
PL Nut
 
Posts: 23
Joined: 3:48am, Wed 25 Oct, 2006

Postby H2B2 » 12:29am, Mon 13 Nov, 2006

Thanks for sharing your solution Rob.

To display the full code, i.e. avoid the code being truncated, you should re-post and re-paste the code and make sure you click on "Disable HTML in this post" on the left hand side of your editing window.
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby robpet » 1:20am, Mon 13 Nov, 2006

One last try with H2B2's suggestion:


<html>
<head>
<title>Birthday Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<?

$dbh=mysql_connect ("localhost", "USERNAME", "PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("DATABASE");
$sql = 'SELECT * FROM `phplist_user_user_attribute`';
$result=mysql_query($sql);
$num=mysql_numrows($result);
mysql_close();

$dbh=mysql_connect ("localhost", "USERNAME", "PASSWORD") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("DATABASE");
$sql = 'SELECT * FROM `phplist_user_user`';
$emails=mysql_query($sql);
$total=mysql_numrows($emails);
mysql_close();


echo "<b><center>Database Output</center></b><br><br>";
$today = mktime(0, 0, 0, date("m"), date("d"), date("y"));

$i=0;
$count = 0;
$success = 0;

while ($i < $num) {
$id=mysql_result($result,$i,"attributeid");
$test=mysql_result($result,$i,"userid");
$birthday=mysql_result($result,$i,"value");
$month = substr($birthday, 5, 2);
$day = substr($birthday, 8, 2);

if ($id == 1){
$firstName = $birthday;
}
if ($id == 11 && $month == date("m") && $day == date("d")) {
$j=0;
while ($j < $total) {
$memberNum=mysql_result($emails,$j,"id");
$email=mysql_result($emails,$j,"email");
$confirmed=mysql_result($emails,$j,"confirmed");

if($memberNum == $test)
{
$sendTo = $email;
$optIn = $confirmed;

if($optIn == 1)
{
echo $sendTo . "<BR>" . $optIn . "<BR>" . $firstName . "<BR>" . $id . "<BR>" . $test ."<BR>" . $birthday . "<BR>" . $month . " " . $day . "<BR>" . "<BR>";
$count++;

$myFile = "birthday.html";
$fh = fopen($myFile, 'r');
$HTML = fread($fh, filesize($myFile));
fclose($fh);
$from = "EMAILADDRESS";
$to = "$SENDTO - PROBABLY WITHOUT THE QUOTES";
$subject = "I'm sending a test HTML email";

sendHTMLemail($HTML,$from,$to,$subject);
}
}
$j++;
}
}
$i++;
}

echo "The total number of people with this birthday is " . $count . ".<BR>";
echo $success . " emails successfully sent.";

function sendHTMLemail($HTML,$from,$to,$subject)
{
// First we have to build our email headers
// Set out "from" address

$headers = "From: $from\r\n";

// Now we specify our MIME version

$headers .= "MIME-Version: 1.0\r\n";
// Create a boundary so we know where to look for
// the start of the data
$boundary = uniqid("HTMLEMAIL");

// First we be nice and send a non-html version of our email

$headers .= "Content-Type: multipart/alternative;".
"boundary = $boundary\r\n\r\n";

$headers .= "This is a MIME encoded message.\r\n\r\n";

$headers .= "--$boundary\r\n".
"Content-Type: text/plain; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";
$headers .= chunk_split(base64_encode(strip_tags($HTML)));

// Now we attach the HTML version
$headers .= "--$boundary\r\n".
"Content-Type: text/html; charset=ISO-8859-1\r\n".
"Content-Transfer-Encoding: base64\r\n\r\n";

$headers .= chunk_split(base64_encode($HTML));

if (mail($to,$subject,"",$headers)) {
global $success;
$success++;
}
}
?>
</head>
<body>
</body>
</html>
robpet
PL Nut
 
Posts: 23
Joined: 3:48am, Wed 25 Oct, 2006

did anyone try this ?

Postby vanzellini » 7:00pm, Fri 05 Jan, 2007

I just want to know before I implement it if this hack actually work, please let know how was your experience with it :)
vanzellini
phpList newbie
 
Posts: 1
Joined: 6:44pm, Fri 05 Jan, 2007

Postby robpet » 7:42pm, Fri 05 Jan, 2007

Yes, it works.

But as I mention, it has to be run in a browser, and I don't know how to do Crons yet...nor do I have it personalizing or creating reports.

So if you need none of that, this will work fine.

If you make any improvements to make this work, let me know, I'd like to take advantage.


Good luck.
robpet
PL Nut
 
Posts: 23
Joined: 3:48am, Wed 25 Oct, 2006

Postby dwalley » 10:06pm, Fri 12 Jan, 2007

How do you enable the PhpList to take down their Birthdays? Cant find it.
dwalley
phpLister
 
Posts: 12
Joined: 2:49pm, Thu 11 Jan, 2007

Postby robpet » 12:17am, Sat 13 Jan, 2007

You'll have to configure it as an attribute. There is an option for "Date", and just name it birthday. Then it will work.

I also advise you to make sure that you tweak the years so it is in the range of what you want. Because I do several things with dates (including post-dat ing messages), I have mine set back 75 years, all the way up to next year (which is 2008 at time of writing).


Good luck.
robpet
PL Nut
 
Posts: 23
Joined: 3:48am, Wed 25 Oct, 2006

Postby SynysterGates » 10:42am, Fri 23 Feb, 2007

Anyone?

Can this be used with Crons?
And does anybody have a clue on how to personalize it?

I really need this :!:
SynysterGates
phpList newbie
 
Posts: 4
Joined: 1:13am, Thu 22 Feb, 2007

Postby jbooker » 8:07pm, Fri 06 Jul, 2007

Has anyone set this up to use a cron job?
jbooker
phpList newbie
 
Posts: 3
Joined: 8:00pm, Mon 02 Jul, 2007

Next

Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 0 guests