Can I do this with PHP? (E-mail autoresponder)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
eysikal
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 2:13 pm

Can I do this with PHP? (E-mail autoresponder)

Post by eysikal »

I'd like to create a script that can respond to text messages sent from my mobil phone.

Maybe some of you are familiar with Google's SMS service. You can send a text message to 46645(GOOGL) with something like "weather los angeles, ca." Google responds with the weather info.

I'd like to do something similar if possible, but I'm having a hard time conceptualizing it.

I suppose I would need a script that is constantly checking for changes on the e-mail server. Once it dectects a new message, it would need to be smart enough to know if it was sent from my phone. Then I could do the proper processing and return the info.

I don't really have an idea of where to start on the code to detect an e-mail(text) message.

Any ideas/suggestions would be appreciated.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you could certainly do that.

you would have to do as you suggested and create a cron to pop to a mail server (assuming you're set on using email) and then parse the message to determine how to respond.

after you've figured out how to respond, sending the email back to your phone is a snap.
eysikal
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 2:13 pm

Post by eysikal »

Burrito wrote:you could certainly do that.

you would have to do as you suggested and create a cron to pop to a mail server (assuming you're set on using email) and then parse the message to determine how to respond.

after you've figured out how to respond, sending the email back to your phone is a snap.
Ok what is a "cron?"

I think I can figure out the parsing of the message and all that. It's just the detecting of the message that I am stuck on. Not sure where to start on that.
eysikal
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 2:13 pm

Post by eysikal »

I guess I'll try to go figure it out. But some direction would be nice.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

eysikal wrote:I guess I'll try to go figure it out. But some direction would be nice.
CRON is task-scheduler for linux (but better :P).

Assuming you can get your SMS to foward to an email inbox the next things sou'll want to look at are:

IMAP Functions (used for POP3 and NNTP too)
eysikal
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 2:13 pm

Post by eysikal »

d11wtq wrote:
eysikal wrote:I guess I'll try to go figure it out. But some direction would be nice.
CRON is task-scheduler for linux (but better :P).

Assuming you can get your SMS to foward to an email inbox the next things sou'll want to look at are:

IMAP Functions (used for POP3 and NNTP too)
Well text messages work like e-mail. You can send a message like this "1234567891@tmomail.net" and it will be received like a text message.

But I don't know how I am going to send one from my phone. Haha, guess I should have thought about that.

Any ideas?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I hope that's not your phone number... I've removed it just in case 8O
eysikal
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 2:13 pm

Post by eysikal »

Burrito wrote:I hope that's not your phone number... I've removed it just in case 8O
Haha, no it's not. I'm not that dumb.
eysikal
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 2:13 pm

Post by eysikal »

Well I'm starting to think there's no way to do this. Unless I can somehow forward messages sent to my phone number to another e-mail address. Or do you think I would be able to monitor T-mobile's e-mail server?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

eysikal wrote:Well I'm starting to think there's no way to do this. Unless I can somehow forward messages sent to my phone number to another e-mail address. Or do you think I would be able to monitor T-mobile's e-mail server?
Excuse my ignorance here... in the UK SMS messages from mobile phones have nothing at all to do with email (been discussed here before). When the messages sent to your email address reaches your cell phone does it also get copied to your email inbox with your service provider (T-Mobile?). In which case, you would have a login username/password for that email address and hence, you can use PHP with the IMAP functions above to check for new messages.
eysikal
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 2:13 pm

Post by eysikal »

I'm not sure. All I know is that sending a e-mail to a number like 1234567890@tmomail.net will end up the phone with that number. I'm doing some research right now to try to figure this all out.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Basically you have two problems:

(1) Fetching and analyzing e-mail messages and finding out where it came from (sms provider) and the eventual body...
(2) Sending back an e-mail with the wanted answer...

I prefer to use fetchmail and procmail for (1) and phpmailer for (2).
eysikal
Forum Newbie
Posts: 13
Joined: Thu May 11, 2006 2:13 pm

Post by eysikal »

timvw wrote:Basically you have two problems:

(1) Fetching and analyzing e-mail messages and finding out where it came from (sms provider) and the eventual body...
(2) Sending back an e-mail with the wanted answer...

I prefer to use fetchmail and procmail for (1) and phpmailer for (2).
Shoot, unfortunately I'm not running linux. Maybe I should set a partition and load it up.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

Apparently all these tools are available for Win32 too... And i suppose Cygwin has them too..
Post Reply