PDA

Click to See Complete Forum and Search --> : Auto Email Checker - [Advice Needed]


modpluz
Apr 11th, 2009, 07:43 AM
good day and season greetings,

am not sure as to how to explain this, i want a cron job to check if there are any new emails for a subdomain.

the domain being something like, posts.mysite.com - so if an email is sent to 33409@posts.mysite.com(which does not exists).it should be posted to an application on my website.

the cron job(i can do), but with the emails, am thinking i should create a CatchAll email address on that subdomain.so any new emails in the CatchAll address should be validated then sent to the application.

what do you think?

and oh, my language is PHP.

dclamp
Apr 11th, 2009, 01:13 PM
Yes, you are going to want to use CatchAll for that subdomain.

Then use IMAP (http://www.php.net/imap) to go through the emails, and do what you need.

modpluz
Apr 14th, 2009, 05:52 AM
Thanks for the reply dclamp, i'll go through the IMAP reference.

on more thing, am using cPanel and i just discovered that there is a way to pipe emails sent to a non-existing address to a program.

but how do i write my script to detect the To/Subject/Body of the message(cos, am thinking the script won't receive the email as an actual email message).

well...i don't know if this makes sense to anyone here(except myself).

dclamp
Apr 14th, 2009, 05:53 PM
I understand waht your saying. With IMAP there are strings for to/subject/body/etc...

Just read over the reference, and it should help. If you are going with PHP, This thread should be moved.

modpluz
Apr 14th, 2009, 09:50 PM
thanks dclamp, i guess i'll have to pay more attention to IMAP.

but what if my web host does not support it, POP is supported - will it work?

and yes my language is PHP.

mendhak
Apr 15th, 2009, 03:30 AM
Thanks dclamp, moved to PHP forum.

dclamp
Apr 15th, 2009, 06:29 PM
i am pretty sure IMAP supports pop connections. Might want to double check. Have you started anything yet?

modpluz
Apr 16th, 2009, 06:36 AM
yes, i have(but locally).
what i noticed is that it refuses to open the protocol on all my ports(143/IMAP, 110/POP3).

it keeps returning with the error

Warning: imap_open() [function.imap-open]: Couldn't open stream {localhost:110}INBOX in D:\dirname\xampp\htdocs\test.php on line 106

Fatal error: Maximum execution time of 60 seconds exceeded in D:\dirname\xampp\htdocs\test.php on line 106


and i don't know why.

kows
Apr 16th, 2009, 03:22 PM
post your code.

modpluz
Apr 18th, 2009, 06:01 AM
ok, well here's the code

$server = "{localhost:110}INBOX";
$link=imap_open($server,"username","password");
$headers = imap_headers($link);

for($x=1; $x < count($headers); $x++) {
$idx=($x-1);
echo "<a href=\"view.php3?num=$x\">$headers[$idx]</a><br>";
}


and the response again is

Warning: imap_open() [function.imap-open]: Couldn't open stream {localhost:110}INBOX in D:\dirname\xampp\htdocs\test.php on line 106

Fatal error: Maximum execution time of 60 seconds exceeded in D:\dirname\xampp\htdocs\test.php on line 106

kows
Apr 18th, 2009, 03:33 PM
if you're trying to connect to a pop3 server (because you said above you weren't sure if your host supported imap?), then you need to specify that:
// To connect to a POP3 server on port 110 on the local server, use:
$mbox = imap_open ("{localhost:110/pop3}INBOX", "user_id", "password");
you can read more here (http://ca3.php.net/manual/en/function.imap-open.php).

also, using "localhost" requires you to actually have a mail server installed on your system. if you do not, then you just need to replace that with an actual mail server, like mail.mydomain.com.

modpluz
Apr 20th, 2009, 06:00 AM
also, using "localhost" requires you to actually have a mail server installed on your system. if you do not, then you just need to replace that with an actual mail server, like mail.mydomain.com.

i do have a local mail server(Mercury).

i did tried the above example, no errors but it returned nothing(mind you, the mailbox has over 10 messages in it).

kows
Apr 20th, 2009, 01:32 PM
well, my test script that logs into gmail via IMAP and dumps my mailbox works fine, so I'm not sure what to tell you. make sure your username is the full emailaddress@domain.com and not just emailaddress. I also read this comment on php.net, you may want to try it:

Beginning with 5.2.2, binaries built for Windows also seem to have changed its default behavior.
'/notls' needs to be specified for a non-SSL connection.

if you can, I might also try to use an outside mail server that you know is operating correctly (just in case yours might not be).