473,395 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

rss to email script?

Hi,

is there a script out there that can send RSS feeds to a given email
account? I have search the usual suspects (google, SF, FM, hotscripts) but
could not find anything

thanks

Oliver

Jul 17 '05 #1
4 7868
NC
Oliver Spiesshofer wrote:

is there a script out there that can send RSS feeds to a given email
account?


It's a two-line affair, really:

$rss_feed = file_get_contents('http://example1.com/feed.rss');
mail('u***@example2.com', 'RSS Feed from Example1.com', $rss_feed,
'Content-Type: application/rss+xml');

Cheers,
NC

Jul 17 '05 #2
"NC" <nc@iname.com> wrote in news:1109098736.662898.47610
@c13g2000cwb.googlegroups.com:
Oliver Spiesshofer wrote:

is there a script out there that can send RSS feeds to a given email
account?


It's a two-line affair, really:

$rss_feed = file_get_contents('http://example1.com/feed.rss');
mail('u***@example2.com', 'RSS Feed from Example1.com', $rss_feed,
'Content-Type: application/rss+xml');


yes but not exactly what I want.
I want each item of the rss sent as a seperate email with the proper $from
$subject etc fields filled in so I can mark single items as read. Also, it
should not send anything twice, and check for new items in the rss feed at
a given interval.

Oliver

Jul 17 '05 #3
NC
Oliver Spiesshofer wrote:
is there a script out there that can send RSS feeds to
a given email account?


It's a two-line affair, really:

$rss_feed = file_get_contents('http://example1.com/feed.rss');
mail('u***@example2.com', 'RSS Feed from Example1.com', $rss_feed,
'Content-Type: application/rss+xml');


yes but not exactly what I want.
I want each item of the rss sent as a seperate email with
the proper $from $subject etc fields filled in so I can mark
single items as read. Also, it should not send anything twice,
and check for new items in the rss feed at a given interval.


Ah, now we are talking specifications... First of all, "check
for new items in the rss feed at a given interval" cannot be
implemented in PHP; you'll have to use OS-level scheduling
facilities for that.

Given your preference for itemization, I don't think you'll be
able to find anything that will fit you out of the box. This,
however, should get you started:

$content = file_get_contents('http://example1.com/feed.rss');
$p = xml_parser_create();
xml_parse_into_struct($p, $content, $vals, $index);
xml_parser_free($p);
unset($content);
foreach ($index['LINK'] as $key => $link_id) {
$title_id = $index['TITLE'][$key];
$description_id = $index['DESCRIPTION'][$key];
$title = $vals[$title_id]['value'];
$link = $vals[$link_id]['value'];
$description = $vals[$description_id]['value'];
$subject = 'Example1.com: ' . $title;
$message = $title . "\r\n" . $link . "\r\n\r\n" .
wordwrap($description, 72, "\r\n");
mail('u***@example2.com', $subject, $message);
}

The only functionality missing from your request is "it should
not send anything twice". You can implement it by creating
a log file or a database where you will store URLs of pages
whose descriptions have already been sent. Let's say you
implemented these two functions:

boolean link_logged(string $link)
Returns true if $link is already in the database or false
otherwise.

void log_link(string $link)
Adds a new record to the log.

Then your code can morph into something like this:

$content = file_get_contents('http://example1.com/feed.rss');
$p = xml_parser_create();
xml_parse_into_struct($p, $content, $vals, $index);
xml_parser_free($p);
unset($content);
foreach ($index['LINK'] as $key => $link_id) {
$title_id = $index['TITLE'][$key];
$description_id = $index['DESCRIPTION'][$key];
$title = $vals[$title_id]['value'];
$link = $vals[$link_id]['value'];
$description = $vals[$description_id]['value'];
if (!link_logged($link)) {
$subject = 'Example1.com: ' . $title;
$message = $title . "\r\n" . $link . "\r\n\r\n" .
wordwrap($description, 72, "\r\n");
mail('u***@example2.com', $subject, $message);
log_link($link);
}
}

Proper "From:" heading is still missing, but it wouldn't be
too hard to add...

Cheers,
NC

Jul 17 '05 #4
thanks a lot for your help.
Finally I took a RSS parser (DOMIT) and made a database, cronjob etc.

You can take a look at it at

http://tokyoahead.com/main/staticpag...age=newsmailer

You have t oregister on the site however in order to verify the email
address...

Oliver

Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: krystoffff | last post by:
Hi all ! I've got a very weird problem ! I was trying to make my PHP script to send emails to every subscribed member to go faster (each email takes 1 or 2 seconds to be sent !) so I tried to...
12
by: Chuck Anderson | last post by:
Can anyone point me in the right direction? I want to use Php to automate confirmation of someone joining an email list by them replying to an email (so they don't have to have a browser?). I...
9
by: mcp6453 | last post by:
I'm posting in desperation and hopes that someone has a script that will achieve these objectives: 1. Web interface using forms collects Name, Address, Email Address. 2. Web interface sends this...
4
by: Bill | last post by:
Is it possible to somehow activate a page containing a php script by sending an email to a mailbox on the server? I have a script that sends out notification emails to an individual. He wants to...
0
by: John Silver | last post by:
I have a perl script running on machine A, a web server. A visitor completes certain pieces of data and these are compiled into two emails, one addressed to the visitor and copied to the site...
4
by: web_design | last post by:
I put this together from some other scripts I am using on a site. I'm trying to make a better email hiding script. It isn't working. Also, it causes Internet Explorer 6 SP2 to block the script...
2
by: E.T. Grey | last post by:
Is it possible to have a PHP script receive an email (CSV text). The problem is this, I want a server to send me an email, and then I want to be able to have a PHP script 'listening' for email and...
4
by: ianbarton | last post by:
Hello all I am trying to setup a feedback form on my webpage using some script provided by my ISP. I really don't know a lot about PHP and it's syntax etc. The feedback form only has 4...
9
by: Jerim79 | last post by:
I am no PHP programmer. At my current job I made it known that I was no PHP programmer during the interview. Still they have given me a script to write with the understanding that it will take me a...
6
by: cfish | last post by:
I'm trying to script my contact page and I have everything the way I want it however I cannot get my script to output Address, City, State, Zip & Phone Number when I get a email. It will output...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.