mIRC Home    About    Download    Register    News    Help

Print Thread
#134547 02/11/05 08:37 AM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
I've recently been working on an login system for my brothers bot but when they register they are to get an e-mail with an authorization code which for now have been manually sending emails to registrants. So I've been asked to make an e-mail sender... Here's the code.

Code:
alias mail {
  set %email.username <hidden>
  set %email.password <hidden>
  sockopen mail mail.mysticirc.co.uk 80
}

on *:sockopen:mail: {
  sockwrite -n $sockname GET $+(/mail/login.html?username=,%email.username,&password=,%email.password) HTTP/1.1
  sockwrite -n $sockname Host: $+(mail.mysticirc.co.uk,$crlf,$crlf)
}

alias email.authenticate {
  sockopen email.authenticate mail.mysticirc.co.uk 80
}

on *:sockread:mail: {
  if ($sockerr) {
    halt
  }
  else {
    var %location
    sockread %location
    if (Location: isin %location) {
      set %email.return $gettok(%location,2,61)
      email.authenticate
    }
  }
}

on *:sockopen:email.authenticate: {
  sockwrite -n $sockname GET $+(/mail/writemail.html?id=,%email.return) HTTP/1.1
  sockwrite -n $sockname Host: $+(mail.mysticirc.co.uk,$crlf,$crlf)
}

on *:sockread:email.authenticate: {
  if ($sockerr) {
    halt
  }
  else {
    var %email
    sockread %email
    if (<title>CYBUTEK WebMail Service (*) - Write Message</title> iswm %email) {
      echo -a sockwrite -n email.authenticate POST $+(/mail/writeaction.html?id=,%email.return,&,writeto=,%email.address,&writesubject=,%email.subject,&writebody=,%email.message)
    }
  }
}


The code above connects to the mail server and logs in with the username and password. I then get an ID returned (%email.return) with that ID I then login to the send email page opening a new socket connection.

I'm very new to the POST command so I dont know how that goes.

The id part in the code above can be "d728ebb9bc564ac0581bcd574be887ce" for example that shows I am logged in I believe...

If I was to go to:

http://mail.mysticirc.co.uk/mail/writeac...itesubject=some subject&writebody=some message

That would send to the email providing the ID is correct but in the code I'm not too sure how to send the data, any help?

-Andy

#134548 02/11/05 07:10 PM
Joined: Dec 2004
Posts: 81
N
Babel fish
Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
Well this may help or may not help. First off, you'de have to replace any spaces in the subject and body fields with the corresponding character that server recognizes as spaces. Some servers use %20 and some (such as google uses +). Once you've figured that part out you can do something like so:

Code:
sockwrite -n <sockname> POST /mail/writeac...itesubject=some subject&writebody=some message


I could be wrong though. As an alternative, you could always use a free pop3 server and send the emails that way smile (bluebottle.com offers free pop3 service)

Last edited by nycdiesel; 02/11/05 07:17 PM.
#134549 02/11/05 07:18 PM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
OP Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Well as a test I had one worded subject & body message it just doesn't seem to send. When I evaluated the writeaction.html code to get the ID I typed it up into my browser with the recipient,subject,message it sent to the email address right away.

-Andy

#134550 02/11/05 07:24 PM
Joined: Dec 2004
Posts: 81
N
Babel fish
Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
I'm not too sure on this one but I'm assuming the server sends a cookie or initiates a session. Meaning you'de have to somehow accept this cookie/session and store that data somewheres to be able to use the POST command effectively. Like I said I could be completely wrong, heh. I'de just use a smtp server for sending e-mails, which obtaining a free pop3 account would enable you to do this. Maybe someone else will think of a way for what you're attempting to do, to work. Sorry I couldn't be that much of a help ;/

#134551 02/11/05 07:33 PM
Joined: Dec 2004
Posts: 81
N
Babel fish
Offline
Babel fish
N
Joined: Dec 2004
Posts: 81
Actually if the mail server you're using supports pop3 access then there is no need to obtain another one. If you want to try the pop3 method, let me know and I'll be more than willing to help wink

#134552 02/11/05 08:01 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Quote:
First off, you'de have to replace any spaces in the subject and body fields with the corresponding character that server recognizes as spaces. Some servers use %20 and some (such as google uses +).


Just so that you know, you can use %20 and it will work fine, even on sites that use +. I think the reverse is also true, though I have not tested that.


Invision Support
#Invision on irc.irchighway.net

Link Copied to Clipboard