How to update blog by sending email using php

I want to update my blog by sending an email using php. This is not wordpress, tumblr or famous.

I can customize the email id with specific code in the subject line, but how do I inject the content into the db?

Thanks Jean

+2


a source to share


5 answers


You can set up a cronjob starting every x minutes and checking for new mail. Use PHP imap functions to fetch and parse mail, then dump the content into your database.



http://php.net/manual/de/book.imap.php

+2


a source


Like others have suggested, you suggested polling the mailbox to detect an incoming message, but it is much more efficient to get an MDA (mail delivery agent) to start the process when a message arrives - how you do this depends on how your mail is (on most Linux systems, procmail used for MDA, which provides all kinds of filtering, automatic replies, and execution functionality, otherwise the .forward files in the user's home directory can usually do at least part of the job).

In terms of parsing the message - it must contain one or more headers, separated by a newline character (or carriage return + newline), followed by at least one blank line, followed by a body. But you need to think about how you work with mime encoded content.

Regardless of how you receive the email, you still need to blog it.

Most blogging software supports some form of xmlrpc for adding posts - there the lib is posted at http://phpxmlrpc.sourceforge.net/



Take a look at the talk pages for examples of use as a client.

Failed - Try reverse engineering the form used to submit the new message.

FROM.

+1


a source


You probably need to do socket programming to listen to an incoming email port and whenever you receive an email over the port (make sure you follow the correct protocols at higher levels) you can take the body and subject and post it in your blog database.

You will need to maintain the script in a loop. However, this kind of task is usually not done on a platform like PHP. You can use console applications to run on your server in C or C ++ to perform whatever tasks are more appropriate.

Allocate PHP to serve up your website / server front end.

0


a source


You can use a task scheduler like cron to periodically check for new emails and update the database.

Or use a web service like webcron http://www.webcron.org/ to run your cron-like script.

0


a source


You will need to use PHP to regularly check your email account with something like POP3. This blog post talks about how to do it

0


a source







All Articles