Solved

PHP based mail to news

Posted on 2002-04-03
4
193 Views
Last Modified: 2006-11-17
I would like to create a news area on a website. I would like the news to be written by a community of people. Is there a way I can have the news updated via email? Where the body of the email message becomes the news text? Then I would just have to give an email address to potential news contributors. I know http://www.k10k.net has done this via ASP, can it be done in PHP?
0
Comment
Question by:kaarsenmaker
  • 2
4 Comments
 
LVL 6

Expert Comment

by:christopher sagayam
ID: 6916681
yes it can be done read more in

http://www.ii.com/internet/robots/procmail/
0
 

Author Comment

by:kaarsenmaker
ID: 6919756
is there a way to do this without using a special server tool, just through php?
0
 

Accepted Solution

by:
papygwen earned 200 total points
ID: 6922621
Hello Kaarsenmaker.
Here is how to process :

1. Your PHP script will have to be in a "cron" so as to run automatically each 10 minutes for instance
2. Create a dedicated mailbox aka news@mysite.com
3. make a readnews.php script in a protected folder using the IMAP functions. Even if in PHP it is called IMAP, it works fine with the POP3 mailboxes

Here is what it should look like :
Open the mailbox : $mbox = imap_open ("{localhost:110/pop3} INBOX", "user_id", "password");
How many emails ? $hmany = imap_num_msg($mbox);

Make a loop with $hmany with in it ("for" $i):
Get the body : $msg = imap_body($mbox, $i);
Insert it in your table : insert into mynews ($msg);
(Add the fields of your table : ID, date, etc...)
Mark the email as read : imap_delete ($mbox, $i);
End of your loop

Delete the marked messages : imap_expunge ($mbox);
Close the mailbox : imap_close ($mbox);

=> Be very carefull with the management of error messages which often occur !!!!!

May it help...





0
 

Author Comment

by:kaarsenmaker
ID: 6925490
thanx that has seemed to work. I ppreciate the efforts.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now