|
-
Apr 11th, 2009, 07:43 AM
#1
Thread Starter
Fanatic Member
Auto Email Checker - [Advice Needed]
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 [email protected](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.
-
Apr 11th, 2009, 01:13 PM
#2
Re: Auto Email Checker - [Advice Needed]
Yes, you are going to want to use CatchAll for that subdomain.
Then use IMAP to go through the emails, and do what you need.
-
Apr 14th, 2009, 05:52 AM
#3
Thread Starter
Fanatic Member
Re: Auto Email Checker - [Advice Needed]
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).
-
Apr 14th, 2009, 05:53 PM
#4
Re: Auto Email Checker - [Advice Needed]
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.
-
Apr 14th, 2009, 09:50 PM
#5
Thread Starter
Fanatic Member
Re: Auto Email Checker - [Advice Needed]
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.
-
Apr 15th, 2009, 03:30 AM
#6
Re: Auto Email Checker - [Advice Needed]
Thanks dclamp, moved to PHP forum.
-
Apr 15th, 2009, 06:29 PM
#7
Re: Auto Email Checker - [Advice Needed]
i am pretty sure IMAP supports pop connections. Might want to double check. Have you started anything yet?
-
Apr 16th, 2009, 06:36 AM
#8
Thread Starter
Fanatic Member
Re: Auto Email Checker - [Advice Needed]
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.
-
Apr 16th, 2009, 03:22 PM
#9
Re: Auto Email Checker - [Advice Needed]
-
Apr 18th, 2009, 06:01 AM
#10
Thread Starter
Fanatic Member
Re: Auto Email Checker - [Advice Needed]
ok, well here's the code
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
-
Apr 18th, 2009, 03:33 PM
#11
Re: Auto Email Checker - [Advice Needed]
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:
PHP Code:
// 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.
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.
-
Apr 20th, 2009, 06:00 AM
#12
Thread Starter
Fanatic Member
Re: Auto Email Checker - [Advice Needed]
 Originally Posted by kows
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).
-
Apr 20th, 2009, 01:32 PM
#13
Re: Auto Email Checker - [Advice Needed]
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 [email protected] and not just emailaddress. I also read this comment on php.net, you may want to try it:
Code:
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).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|