boardom Forum Index boardom
b2 message board
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[BETA-TEST] b2mail.php - blog by email
Goto page 1, 2  Next
 
Post new topic   Reply to topic    boardom Forum Index -> Hacks
View previous topic :: View next topic  
Author Message
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Tue Jun 18, 2002 12:06 am    Post subject: [BETA-TEST] b2mail.php - blog by email Reply with quote

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 Very Happy</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 Very Happy</b>

in the category that has ID #4.


Have fun testing this baby Very Happy

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
GamerZ



Joined: 15 May 2002
Posts: 537
Location: Singapore

PostPosted: Tue Jun 18, 2002 6:12 am    Post subject: Reply with quote

COOL
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
feelso



Joined: 30 May 2002
Posts: 52
Location: Paris, France

PostPosted: Thu Jun 20, 2002 5:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Sun Jun 23, 2002 2:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
feelso



Joined: 30 May 2002
Posts: 52
Location: Paris, France

PostPosted: Mon Jun 24, 2002 11:16 pm    Post subject: Reply with quote

and what about the line breaks?

it doesn't seem to work too...
Back to top
View user's profile Send private message
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Wed Jun 26, 2002 11:26 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
ailios



Joined: 25 Jan 2002
Posts: 5

PostPosted: Fri Jun 28, 2002 12:56 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Sat Jun 29, 2002 3:42 pm    Post subject: Reply with quote

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 Smile


Last edited by michel v on Tue Jul 09, 2002 3:29 am; edited 5 times in total
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
ailios



Joined: 25 Jan 2002
Posts: 5

PostPosted: Mon Jul 01, 2002 11:31 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
simone



Joined: 01 Jul 2002
Posts: 2

PostPosted: Tue Jul 02, 2002 12:13 am    Post subject: Reply with quote

michel v wrote:

Anyway, it's been working for Mr Cortesi ;)
http://cortesi.com/blog/index.php?p=5

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
View user's profile Send private message
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Tue Jul 02, 2002 12:28 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
michel v
Site Admin


Joined: 25 Jan 2002
Posts: 799
Location: Corsica

PostPosted: Tue Jul 02, 2002 12:30 pm    Post subject: Reply with quote

simone wrote:

michel v wrote:

Anyway, it's been working for Mr Cortesi
http://cortesi.com/blog/index.php?p=5

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
tgillespie



Joined: 02 May 2002
Posts: 9

PostPosted: Mon Jul 15, 2002 4:59 pm    Post subject: Reply with quote

the links are dead to the files:

b2mail.phps &
class.POP3.phps

Probably didnt get copied when you made the move
_________________
http://custercountydirect.com
http://mods.mohmatch.com
Back to top
View user's profile Send private message Send e-mail
ailios



Joined: 25 Jan 2002
Posts: 5

PostPosted: Fri Jul 19, 2002 7:41 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
reber



Joined: 21 May 2002
Posts: 10
Location: Juneau, Alaska

PostPosted: Mon Jul 22, 2002 5:14 pm    Post subject: Reply with quote

Wish the b2mail links were live again!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    boardom Forum Index -> Hacks All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB 2 © 2001, 2002 phpBB Group