Solved

PHP based mail to news

Posted on 2002-04-03
4
194 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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.

770 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