View previous topic :: View next topic |
Author |
Message |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Tue Jun 18, 2002 12:06 am Post subject: [BETA-TEST] b2mail.php - blog by email |
|
|
This is something that isn't released yet because I need to find a way to handle HTML messages sent by Outlook express.
You can get the script here:
http://cafelog.com/06p3/b2mail.phps - save as b2mail.php and put with your b2 files
And the necessary POP3 class here:
http://cafelog.com/06p3/b2-include/class.POP3.phps - save as class.POP3.php3 and put in /b2-include
Edit b2mail.php, with your email details. It's a good thing to create a new POP3 mailbox just for that script, though you can use your exisitng one.
Then, you run the script with a cron (since this can be resource intensive, I advise you not to set the cron to run every minute if you're on shared hosting...).
What the script does:
- checks your POP3 for messages
- checks all messages for a subject like "blog:here is the title of that post"
- checks that the first line of such a message is like "login:password"
- posts the content starting from the second line, stopping at the message delimiter '___' by default (to defeat sigs and ads from most free email providers like Yahoo! or Hotmail)
- deletes the email message (it doesn't delete emails that do not fit all the conditions, of course)
You can use <title> and <category> to set a title that overrides the subject, and a category that overrides the default category that you set in b2mail.php's settings.
Example email:
Quote: | To
[email protected]
Subject
blog: Hello World
Message
michelv:michelspassword
<category>4</category>Hello, I'm Michel !
There are only email terminals in this computer rooms, but <b>that won't stop me from blogging </b> |
This would make a post with the title:
Hello World
the content:
Hello, I'm Michel !
There are only email terminals in this computer rooms, but <b>that won't stop me from blogging </b>
in the category that has ID #4.
Have fun testing this baby
Note: to make it work, your mail client must be set to send mail as plain text instead of HTML. I'm currently working on making it compatible with HTML emails but it's not that easy -_-
Last edited by michel v on Sun Sep 15, 2002 2:46 pm; edited 1 time in total |
|
Back to top |
|
 |
GamerZ
Joined: 15 May 2002 Posts: 537 Location: Singapore
|
Posted: Tue Jun 18, 2002 6:12 am Post subject: |
|
|
COOL |
|
Back to top |
|
 |
feelso
Joined: 30 May 2002 Posts: 52 Location: Paris, France
|
Posted: Thu Jun 20, 2002 5:20 pm Post subject: |
|
|
It seems that the "apostrophe" is not allowed in the title.
It gives an error and it fucks up all the process...
Is it me or... ? |
|
Back to top |
|
 |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Sun Jun 23, 2002 2:29 pm Post subject: |
|
|
Good call, it was a line I forgot to put there.
Find these lines: Code: | if (!$thisisforfunonly) {
$content = addslashes(trim($content)); |
And add this line right after them: Code: | $post_title = addslashes(trim($post_title)); |
This will make the script accept apostrophes and other characters. |
|
Back to top |
|
 |
feelso
Joined: 30 May 2002 Posts: 52 Location: Paris, France
|
Posted: Mon Jun 24, 2002 11:16 pm Post subject: |
|
|
and what about the line breaks?
it doesn't seem to work too... |
|
Back to top |
|
 |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Wed Jun 26, 2002 11:26 pm Post subject: |
|
|
Oh, uhm I got to make it an option to convert line-breaks. Or make it convert them if AutoBR is On in the Options.
Anyway, it's been working for Mr Cortesi
http://cortesi.com/blog/index.php?p=5 |
|
Back to top |
|
 |
ailios
Joined: 25 Jan 2002 Posts: 5
|
Posted: Fri Jun 28, 2002 12:56 am Post subject: |
|
|
I've got it working fine if I send ordinary email, but what I REALLY want to be able to do is send email from my cell phone. So far that hasn't worked. Maybe because it's all on one line or something? Here's what I type in:
[email protected] blog: Hello login:password message text
It gets confused like it thinks the subject is the login. If I switch positions (login first and subject after) it gets even more confused. I took the subject out in the b2mail.php (just left '') and it's still confused.
Any ideas on how I could make this work?
Daisy
----------------------------
www.daisybrown.com |
|
Back to top |
|
 |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Sat Jun 29, 2002 3:42 pm Post subject: |
|
|
Daisy, I'm not sure.
How does your phone email work ? It looks like you have to put everything on one line, which looks like it's an SMS to POP3 gateway.
Anyway, the only way to debug this would be to output the email to a file.
Here's a way you can do it. Open b2mail.php, and add these lines:
[php:1:048951d0e4]$f = fopen('b2maildebug.txt','a+');
fwrite($f, "\n\n\n---\n\n\n");
$debugmsg = implode("\n", $MsgOne);
fwrite($f, $debugmsg);
fclose($f);[/php:1:048951d0e4]
After this line:
[php:1:048951d0e4]if (preg_match('/'.$subjectprefix.'/', $subject)) {[/php:1:048951d0e4]
Now, create a blank file named b2maildebug.txt, and chmod it 666 so the webserver can write to it.
Each time the b2mail.php will spot an email that suits its requirements, it will output the raw content to b2maildebug.txt
If you could copypaste the raw content of an email sent with your cellphone, I could check what's to correct 
Last edited by michel v on Tue Jul 09, 2002 3:29 am; edited 5 times in total |
|
Back to top |
|
 |
ailios
Joined: 25 Jan 2002 Posts: 5
|
Posted: Mon Jul 01, 2002 11:31 pm Post subject: |
|
|
Here's a copy of the contents of the b2maildebug.txt file (sensitive data has been modified, of course):
Quote: | Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: (qmail 6874 invoked by uid 508); 1 Jul 2002 21:22:49 -0000
Received: from unknown (HELO boca.voicestream.net) (63.122.5.251)
by opie.phpwebhosting.com with SMTP; 1 Jul 2002 21:22:49 -0000
From: <[email protected]>
Subject: blog: Hello World xxx:passord Hello, ...
To: <[email protected]>
blog: Hello World xxx:password Hello, I'm Michel ! |
Thanks!
Daisy |
|
Back to top |
|
 |
simone
Joined: 01 Jul 2002 Posts: 2
|
Posted: Tue Jul 02, 2002 12:13 am Post subject: |
|
|
I was thinking of a new version of your script which will enable me to update the blog thru email. Instead of using crontab to execute the php page. I'm planning to use an alias and php as CLI (command line interface). I.E.: i send a mail to an address on my server, that mail gets immediatly passed to the php interpreter on commandline which update the blog.
I got the inspiration from here: http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/
Michel, what do you think? |
|
Back to top |
|
 |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Tue Jul 02, 2002 12:28 pm Post subject: |
|
|
ailios wrote: |
Here's a copy of the contents of the b2maildebug.txt file (sensitive data has been modified, of course):
Quote: | Return-Path: <[email protected]>
Delivered-To: [email protected]
Received: (qmail 6874 invoked by uid 508); 1 Jul 2002 21:22:49 -0000
Received: from unknown (HELO boca.voicestream.net) (63.122.5.251)
by opie.phpwebhosting.com with SMTP; 1 Jul 2002 21:22:49 -0000
From: <[email protected]>
Subject: blog: Hello World xxx:passord Hello, ...
To: <[email protected]>
blog: Hello World xxx:password Hello, I'm Michel ! |
|
Looks like your phone mail system sends the email with identical subject and content. I'm not sure how to work around that, but I may find a way or release a version tuned for that specificity. |
|
Back to top |
|
 |
michel v Site Admin
Joined: 25 Jan 2002 Posts: 799 Location: Corsica
|
Posted: Tue Jul 02, 2002 12:30 pm Post subject: |
|
|
simone wrote: |
I was thinking of a new version of your script which will enable me to update the blog thru email. Instead of using crontab to execute the php page. I'm planning to use an alias and php as CLI (command line interface). I.E.: i send a mail to an address on my server, that mail gets immediatly passed to the php interpreter on commandline which update the blog.
I got the inspiration from here: http://www.evolt.org/article/Incoming_Mail_and_PHP/18/27914/
Michel, what do you think?
|
That would be workable. The only problem is that most people (who are on shared hosting) do not have shell access, and/or their PHP doesn't allow command-line (which is a very reasonable thing to do security-wise, on shared hosting servers).
I'm going to check how I could write such an interface though |
|
Back to top |
|
 |
tgillespie
Joined: 02 May 2002 Posts: 9
|
|
Back to top |
|
 |
ailios
Joined: 25 Jan 2002 Posts: 5
|
Posted: Fri Jul 19, 2002 7:41 pm Post subject: |
|
|
This weekend I'm going to finally get around to trying out my Palm VII for sending email/posts. In my tests I noticed that the email to post didn't adjust for the time difference of the server. Any way to correct that?
Thanks!
Daisy
-----------------------------
www.daisybrown.com |
|
Back to top |
|
 |
reber
Joined: 21 May 2002 Posts: 10 Location: Juneau, Alaska
|
Posted: Mon Jul 22, 2002 5:14 pm Post subject: |
|
|
Wish the b2mail links were live again! |
|
Back to top |
|
 |
|