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: [email protected]\r\nReply-To: [email protected]";
$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
https://forums.phpfreaks.com/topic/136634-email-multiple-people/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.