Jump to content

Email multiple people


stuffradio

Recommended Posts

Ok,

 

I've been thinking about this too long and I need to pick someones brain on this topic.

 

Here is my code and I'll explain (Btw this is for Wordpress):

 

<?php
global $wpdb;
include_once('../../../wp-load.php');
include_once('../../../wp-includes/rss.php');

$feeds = $wpdb->prefix . "feeds";
$blogs = $wpdb->prefix . "blogentries";
$users = $wpdb->prefix . "users";
$feed_list = $wpdb->get_results("SELECT * FROM $feeds");
$blog_list = $wpdb->get_results("SELECT * FROM $blogs");

$random_hash = md5(date('r', time())); 
$headers = "From: noreply@uddyb.com\r\nReply-To: noreply@uddyb.com";
$headers .= "\r\nContent-Type: multipart/alternative; boundary=\"PHP-alt-".$random_hash."\""; 
$subject = "Your hourly updated feed results";
ob_start();

	foreach ($feed_list as $feedlist):	/* Start foreach */
$getUser = $wpdb->get_var("SELECT user_email From $users WHERE user_login='$feedlist->feedUsers'");		?>

--PHP-alt-<?php echo $random_hash; ?> 
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
<?php $email_message = "Dear $feedlist->feedUsers, in the last hour here are the latest updates from your feeds:\n";



$rss = fetch_rss($feedlist->feedUrl);
$maxitems = 10;
$items = array_slice($rss->items, 0, $maxitems);

	foreach($items as $rsss):
$rss_update .= "<a href='$rsss[link]'>$rsss[title]</a>\n";
$rss_update .= "<br />";
	endforeach;
?>

<?php echo $email_message . $rss_update; ?>

--PHP-alt-<?php echo $random_hash; ?>--
<?php $message = ob_get_clean(); 

	endforeach; /*End Foreach */
mail ($getUser, $subject, $message . $rss_update, $headers);
?>

 

I'm trying to have it mail multiple people, the people who are in the wp_feeds table. I have it setup to select all the rows in wp_feeds, then list all rss updates and then email it.

 

I can get it to email sometimes, but sometimes that doesn't work either. Right now when it emails, it emails everyone, but the $email_message shows up for each entry in wp_feeds.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.