Gossamer Forum
Home : General : Internet Technologies :

PHP: Personalized Mass Email Script

Quote Reply
PHP: Personalized Mass Email Script
Hello.

I've written a Personalized Mass Email PHP script that will send out personalized data in an HTML formatted email to members of our website. I did originally post this issue at PHP Builder Community Forum, but did not receive any workable solutions.

http://www.phpbuilder.com/...&postid=10396332

Everything works except for showing the HTML content (pulled from templates) within the emails sent. What is seen in the emails sent is the following:

1111111111111111111111111111111111111111111111111111

where the personalized data should appear.

Here are the relevant codes that may be causing the problem:

Code:
$messsage = include ('templates/emails/admin_matches_top.php');
if ($check_match_email_rowcount > 0) {
while ($email_row = mysql_fetch_array($check_match_email_get_result)) {
$my_match_email_id = $email_row[0];
$my_match_email_username = $email_row[1];
$my_match_email_age = $email_row[2];
$my_match_email_type = $email_row[3];
$my_match_email_gender = $email_row[4];
$my_match_email_matchGender = $email_row[5];
$my_match_email_caption = $email_row[6];
$my_match_email_hasphoto = $email_row[7];
$my_match_email_state = $email_row[8];
if ($debug == "on") {
print 'USERID: ';echo $my_userid;print'- Matching Record: ';echo $my_match_email_id;print'<br>';
}
$message .= include ('templates/emails/admin_matches.php');
$update_email_log = "UPDATE match_email_log SET emailed = 1, match_email_sent = NOW() WHERE (userID = $my_userid) AND (matchID = $my_match_email_id)";
if ($update_email_result = mysql_query($update_email_log)) {
if ($debug == "on") {
print 'USERID: ';echo $my_userid;print'- Matching Record Updated: ';echo $my_match_email_id;print'<br>';
}
}
else {
if ($debug == "on") {
print 'USERID: ';echo $my_userid;print'- Matching Record Not Updated: ';echo $my_match_email_id;print'<br>';
}
}
}
$message .= include ('templates/emails/admin_matches_bottom.php');
$email_template = "admin_notify_matches.txt";
$email_subject = ": Your Matches";
$emailer = new Emailer;
if ($emailer->send($email_template,
array(
'subject' => $quick_title . $email_subject,
'sender' => $noreplies_email,
'recipient' => $my_email,
'message' => $message,
'general_header' => $mail_general_header,
'header' => $mail_header,
'footer' => $mail_html_footer
)
)) {
if ($debug == "on") {
print 'USERID : ';echo $my_userid;print'-Matching Records-Sending Email';
print '<hr>';
}
}
else {
print 'USERID : ';echo $my_userid;print'-Matching Records-Could not Send Email. Problem with Email Configurations';
print '<hr>';
}

BTW: I am including the correct CONTENT/TYPE header information through the $mail_header variable.

Thanks in advance.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] PHP: Personalized Mass Email Script In reply to
For those interested, I figured out how to solve the above problem....

Basically, I created individual temp email files that contained the HTML formatted message with the appropriate recordset. The logic I employed was as follows:

Code:
--- CREATE TEMP MAIL FILE (with header HTML)
-------------WHILE LOOP
------------------APPEND RECORDS IN FILE
-------------END LOOP
--- APPEND HTML FOOTER

--- SEND EMAIL LOOP
------ OPEN EMAIL TEMPLATE FILE
------ SEND EMAIL
------ DELETE EMAIL TEMPLATE FILE
----END EMAIL LOOP
========================================
Buh Bye!

Cheers,
Me

Last edited by:

Stealth: Aug 10, 2003, 7:10 PM