|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
I've given up on COM objects for now until I can find more examples and tutorials to study and can find something to make with them, but I had an idea and just wanted to see if this was possible. I'd like to make a POP mail checker for mIRC using sockets. Is this possible? I'm not sure about the commands to use to authenticate and then get the data. I'd like to have it so I could see who the email is from and the subject. I don't necessarily need to be able to read the email from mIRC. Another bonus feature would be to delete the email. Thanks.
|
|
|
|
Joined: Jan 2003
Posts: 2,523
Hoopy frood
|
Hoopy frood
Joined: Jan 2003
Posts: 2,523 |
Check out this tutorial for the basics. Generally, keep in mind that this isn't a mirc-related issue, what you actually have to do is read the related RFC document for the protocol you want to implement. That's of course assuming that you have a good understanding of sockets already (there are tutorials for that too, like this one)
/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
Thank you for that help. This looks like it will work pretty easily. One more question for an optional feature. Do you know of any good way to strip out the coding or just retrieve the info that I want. I'd like to see a list of emails, then be able to select one. Once I select one to read, I'd just like to see this:
To: My address here From: Their address Body of message
Thanks for your help.
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
I just got this working enough to echo a whole email message but I changed something and now it won't echo. I can't figure out what I did. Any ideas?
on 1:sockopen:mail:{
echo -a socket opened
}
on 1:sockread:mail:{
var %temptext
sockread %temptext
if %temptext = +OK POP3 server ready. {
sockwrite -n $sockname user MyUserName
sockwrite -n $sockname pass MyPassword
sockwrite -n $sockname list
echo -a %temptext
else { echo -a %temptext
}
}
}
I get the two lines echoed that say: socket opened +OK POP3 server ready. And, yes. MyUserName and MyPassword are the real things in my script, lol. Thanks.
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
you need to work on your brackets:
on 1:sockread:mail:{
var %temptext
sockread %temptext
if %temptext = +OK POP3 server ready. {
sockwrite -n $sockname user MyUserName
sockwrite -n $sockname pass MyPassword
sockwrite -n $sockname list
echo -a %temptext
}
else { echo -a %temptext }
} I cant test it, it doesn't look right to me to post the username and password in the sockREAD, isn't that meant to be on sockOPEN?
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
Please post your solution here, this helps others in the future who might do a search on the forum and need that same info.
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
I fixed it by setting a variable and having it check if it had authenticated already. Now I'm having a problem trying to get it to put an email in a window. Here's the code with the fix, although the window part isn't working.
on 1:sockopen:mail:{
echo -a socket opened
}
on 1:sockread:mail:{
if ($sockerr) {
echo -a Error.
halt
}
else {
var %temptext
sockread %temptext
while (%auth != 1) {
sockwrite -n $sockname user UserName
sockwrite -n $sockname pass Password | set %auth 1
sockwrite -n $sockname list
}
}
unset %auth
sockwrite -n $sockname retr 1
window @mail %temptext
}
I just saw your first post. It might work in either place (sockread or sockopen), but I put it in sockread because when you connect to the mail server, it sends "OK POP3 server ready.", so I figured it would sense that read and work from there.
Last edited by bwr30060; 10/02/06 06:12 PM.
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
Any ideas on why this keeps putting the same email in the window multiple times? I currently have one email on the server that I sent myself, and I put the %retr variable in to stop it from doing it multiple times, but it still repeats. I'm also getting an "aline invalid parameters" message repeatedly in the status window. Thanks.
on 1:sockread:mail:{
window @mail
if ($sockerr) {
echo -a Error.
halt
}
else {
var %temptext
sockread %temptext
while (%auth != 1) {
sockwrite -n $sockname user User
sockwrite -n $sockname pass Password | set %auth 1
sockwrite -n $sockname list
}
}
unset %auth
while (%retr != 1) {
sockwrite -n $sockname retr 1
set %retr 1
}
unset %retr
aline @mail %temptext
}
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
Any ideas on why this keeps putting the same email in the window multiple times? I currently have one email on the server that I sent myself, and I put the %retr variable in to stop it from doing it multiple times, but it still repeats. I'm also getting an "aline invalid parameters" message repeatedly in the status window. Thanks.
on 1:sockread:mail:{
window @mail
if ($sockerr) {
echo -a Error.
halt
}
else {
var %temptext
sockread %temptext
[color:red]while (%auth != 1) {[/color]
sockwrite -n $sockname user User
sockwrite -n $sockname pass Password | set [color:red]%auth 1[/color]
sockwrite -n $sockname list
}
}
[color:red] unset %auth[/color]
while (%retr != 1) {
sockwrite -n $sockname retr 1
[color:red] set %retr 1
}
unset %retr[/color]
aline @mail %temptext
}
you set then right away unset your %vars that are used to check whether or not the script should do that, so every time the sockread fires it logs in, unsets the var then retrieves then unsets that var. put the Unsets in a sockclose event to start with, see what you get then. on *:sockclose:mail:{ unset %retr unset %auth }
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
without diging deeper you probably should do it more like this:
on *:sockopen:mail:{
sockwrite -n $sockname user User
sockwrite -n $sockname pass Password
sockwrite -n $sockname list
sockwrite -n $sockname retr 1
}
on 1:sockread:mail:{
if (!$window(mail)) { window @mail }
window @mail
if ($sockerr) {
echo -a Error.
halt
}
var %temptext
sockread %temptext
if (%temptext) {
aline @mail %temptext
}
}
give that a shot you need to go back and look at documentation for email via mIRC sockets because there is a lot you are missing fex you only get the first email, as that is all you are requesting (and in this example too! I didnt change that) anyway, try this change and see what you get
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
Thanks. I'll try your code. I only have it checking for the first message just because I'm testing. It'll check for all of them once I get it working better. Thanks again.
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
I tried yours and it worked once, and then a bunch of times it only said "+OK POP3 server ready." in the window. I think I might need IF statements for when it's asking for username and password. I think throwing all of the lines at it at the same time can mess it up sometimes. It didn't give me errors, but it didn't do anything else.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
once retieved, does the mail still exist on the server? though I didn't see a command in your code to tell the server to del after you retrieved. Try accessing the mailbox with regular mail software, and send a fresh email to the mailbox.
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
The mail still exists on the server. I'm not actually retrieving it, just viewing it from there (when it works). I have a hunch that it might be that the script is executing the next sockwrite before the mail server is ready for it. I just ran it now and only got: +OK POP3 server ready. This means that the socket opened, but nothing else happened. It's a little odd and frustrating that I didn't get any errors. Do you think that's the case that the script is going too fast for the server? Do I need to analyze everything the server sends me, so I'd have a bunch of statements like:
if (%temptext == +OK POP3 server ready.) { sockwrite -n $sockname user UserName }
if (%temptext == +OK please send PASS command) { sockwrite -n pass Password }
That would make it longer, but I might have to do that.
Last edited by bwr30060; 10/02/06 10:00 PM.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
you may be right, before burning too many braincells you might try this Link
|
|
|
|
Joined: Feb 2004
Posts: 2,019
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 2,019 |
Thanks for referring to my addon.
Note that in the addon pop3 isn't used because Gmail's pop3 requires SSL, something you cannot accomplish with mIRC's socket features, atleast not without a third party application like stunnel.
The addon is tailored specifically for Gmail as what it does is simulate what a web browser sends, and uses COM for some specific parts.
For other email accounts he will not be able to use my addon, but hopefully their pop3 service will not require SSL.
Gone.
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
ah ok, I did a quick search of the forum and yours came up, I remembered you had done one just recently so thought it would be a good one to sample from.
Looks like I may have confused things worse!
|
|
|
|
Joined: May 2005
Posts: 449
Fjord artisan
|
OP
Fjord artisan
Joined: May 2005
Posts: 449 |
I found this POP mail checker and it uses sockmarks. I haven't used them and I'm not familiar with how they work or what they do exactly. Does this make sure they're executed in the right order, and do you need to put something before a line like this to mark them? I didn't see where that was done in this case. I'll post the lines using what I believe are sockmarks.
if ($sock($sockname).mark == 1) { mail.write USER %mail.user | mail.mark 2 | return }
if ($sock($sockname).mark == 2) { mail.write PASS %mail.pass | mail.mark 3 | return }
if ($sock($sockname).mark == 3) { mail.write STAT | mail.mark 4 | return }
if ($sock($sockname).mark == 4) { echo -a -> /mail.check: $2 new mail(s) | mail.write QUIT | mail.mark 5 | unset %mail.user %mail.pass | return }
|
|
|
|
Joined: Dec 2002
Posts: 1,245
Hoopy frood
|
Hoopy frood
Joined: Dec 2002
Posts: 1,245 |
I dont know what to tell you, I look back in this thread and see where Qwerty gave you two really good links to help with this, you can also do a forum search for "email" expand the search period to 5 years and I bet with some diligence you will find good examples (other than the links mentioned above)
|
|
|
|
|