السلام عليكم و رحمة الله
وجدت سكربت يرسل Rss إلى Email
لكن السكربت يستخدم دالة mail في الإرسال
أريد منكم التعديل عليه ليرسل من خلال smtp
كود السكربت
كود PHP:
<?php
/**
* o------------------------------------------------------------------------------o
* | This package is licensed under the Phpguru license. A quick summary is |
* | that for commercial use, there is a small one-time licensing fee to pay. For |
* | registered charities and educational institutes there is a reduced license |
* | fee available. You can read more at: |
* | |
* | http://www.phpguru.org/static/license.html |
* o------------------------------------------------------------------------------o
*
* � Copyright 2008,2009 Richard Heyes
*/
/**
* Some RSS feeds to fetch. It uses a UNIX tmp dir which you will need to change if you're using it on Windows.
*/
$urls[] = 'http://www.phpguru.org/rss.php';
$urls[] = 'http://www.planet-php.org/rss/';
foreach ($urls as $url) {
$rss = file_get_contents($url);
$xml = new SimpleXMLElement($rss);
$cache = '/tmp/rss_' . md5($url) . '.txt';
/**
* Get the cache file. Could replace this with an "inRSSCache()" function
*/
$cache_contents = file_exists($cache) ? file_get_contents($cache) : '';
/**
* Some stuff to use in the email
*/
$feed['title'] = (string)$xml->channel[0]->title;
$feed['link'] = (string)$xml->channel[0]->link;
$feed['description'] = trim((string)$xml->channel[0]->description);
/**
* Print the data
*/
header('(anti-spam-(anti-spam-content-type:)) text/plain');
echo 'Feed: ' . $feed['link'] . "\r\n";
/**
* Loop through all the items in the feed
*/
foreach ($xml->channel->item as $item) {
$url = (string)$item->link;
if (strpos($cache_contents, $url) !== false) {
continue;
}
echo " {$url}\r\n";
// The data from the feed
$title = (string)$item->title;
$link = $url;
$pubDate = (string)$item->pubDate;
$description = ltrim($item->description);
$to = 'postmaster@domain.com'; // Put your email address here
$mail = <<<END
Title: {$title}
URL: {$url}
Date: {$pubDate}
{$description}
END;
mail($to, '[RSS] ' . $title, $mail, "From: {$feed['title']}"); // Might want to put a valid From: address here
// Store the URL in our tmp file for recording which items we've seen
fwrite(fopen($cache, 'a'), $url . "\r\n");
}
}
?>
الرجاء من الإخوة تعديل الكود ووضعه جاهزا و بارك الله في الجميع