mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 2 1 2
Joined: Sep 2008
Posts: 23
P
Ameglian cow
OP Offline
Ameglian cow
P
Joined: Sep 2008
Posts: 23
Weird.. I might have been testing it too many times.
I am getting the "Already sending. Try again later.".

Is there a command to abort sending it? Or do I just wait it out? Restarting does nothing frown

Joined: Sep 2008
Posts: 62
_
Babel fish
Offline
Babel fish
_
Joined: Sep 2008
Posts: 62
There's a design flaw in the code, it doesn't gracefully fall back to defaults in the event of an unknown error (User kills the sockets, mIRC crashes/restarts, etc)

To get it to work again you need to unset the variable it internally sets to gauge if it's currently sending or not, and that is %sndmail.busy

/set %sndmail.busy 0

/unset %sndmail.busy

/unset %sndmail.*

any of those will work. genius_at_work will have to update the code for you to prevent this from happening in the future. A simple on start event, or adding additional checks, or however this code guru decides.

Last edited by _Memo; 18/11/08 10:47 PM.
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Change this line:

Code:

alias mailsockclose { if ($sock($1)) mailsockwrite $1 QUIT }



to this:

Code:

alias mailsockclose { 
  if ($sock($1)) mailsockwrite $1 QUIT 
  .timersmtp2 1 3 mailsockcleanup $1
}

alias mailsockcleanup {
  if ($sock($1)) sockclose $1
  unset %sndmail.*
}

on *:START:{ unset %sndmail.* }



And below this line:

Code:

  set %sndmail.busy 1



add this line:

Code:

  .timersmtp 1 5 mailsockclose sendmail



That should clear out everything created by the script so that you can send again.

-genius_at_work

Last edited by genius_at_work; 19/11/08 01:37 AM.
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Here is a POP3 code:

Code:

alias dogetmail getmail EMAIL_1 smtp.first.com 110 myusername MyPassword $true email\first\

alias dochkmail getmail EMAIL_2 smtp.second.com 110 my.email@second.com ThisPassword $false email\second\

; /getmail [-e] <name> <server> <port> <username> <password> <transfer> <savepath>
;  <name>: Name for this connection, single word only
;  <server>: IP or server of POP3 server
;  <port>: Port of POP3 server
;  <username>: Username for logging into POP3 server
;  <password>: Password for logging into POP3 server
;  <transfer>: $true = Download&DeleteMessages; $false=LeaveOnServer
;  <savepath>: absolute or relative path to save downloaded emails

alias getmail {
  if (-* iswm $1) {
    var %sw = $1
    tokenize 32 $2-
  }

  var %dir = $7
  if (!$isdir(%dir)) mkdir %dir
  if (!$isdir(%dir)) {
    echo 4 -a POP3 $1 * ERROR: Unable to create path %dir
    return
  }

  :picksid
  var %SID = $+(pop.,$ticks,$rand(000,999))
  if ($exists($+($p3get($+(%SID,.path)),%SID,.txt))) goto picksid

  $+(.timer,.,%SID) 1 5 getmailcleanup %SID

  p3add $+(%SID,.name) $1
  p3add $+(%SID,.addr) $2
  p3add $+(%SID,.port) $3
  p3add $+(%SID,.user) $4
  p3add $+(%SID,.pass) $5
  p3add $+(%SID,.save) $6
  p3add $+(%SID,.path) $7

  p3add $+(%SID,.write) 0
  p3add $+(%SID,.state) 1
  if ($sock(%SID)) sockclose %SID
  sockopen $iif(e isin %sw,-e) %SID $p3get($+(%SID,.addr)) $p3get($+(%SID,.port))
}

on *:SOCKOPEN:pop.*:{
  var %SID = $sockname
  echo 3 -a POP3 $p3get($+(%SID,.name)) * Connected to $+($p3get($+(%SID,.addr)),:,$p3get($+(%SID,.port))) as $p3get($+(%SID,.user))
}

on *:SOCKREAD:pop.*:{
  var %s
  sockread %s
  tokenize 32 %s
  ;echo -a > $1-
  var %SID = $sockname
  $+(.timer,.,%SID) 1 5 getmailcleanup %SID

  if (-ERR isin $1) {
    echo 4 -a POP3 $p3get($+(%SID,.name)) * ERROR @ $+ $p3get($+(%SID,.state)) $+ : $1-
    sockwrite -n $sockname QUIT
    p3add $+(%SID,.state)) -1
  }
  elseif ($p3get($+(%SID,.state)) < 0) {
    sockclose $sockname
  }
  elseif ((OK isin $1) && (!$p3get($+(%SID,.write)))) {
    if ($p3get($+(%SID,.state)) == 1) {
      sockwrite -n $sockname USER $p3get($+(%SID,.user))
      p3add $+(%SID,.state)) 2
    }
    elseif ($p3get($+(%SID,.state)) == 2) {
      sockwrite -n $sockname PASS $p3get($+(%SID,.pass))
      p3add $+(%SID,.state)) 3
    }
    elseif ($p3get($+(%SID,.state)) == 3) {
      sockwrite -n $sockname STAT
      p3add $+(%SID,.state)) 4
    }
    elseif ($p3get($+(%SID,.state)) == 4) {
      echo 12 -a POP3 $p3get($+(%SID,.name)) * $2 $iif($2 == 1,message,messages)
      if (($2 > 0) && ($p3get($+(%SID,.save)))) {
        p3add $+(%SID,.count)) 1
        p3add $+(%SID,.state)) 5
        p3add $+(%SID,.num)) $2
        .remove $+($p3get($+(%SID,.path)),%SID,.tmp)
        sockwrite -n $sockname RETR $p3get($+(%SID,.count))
      }
      else {
        sockwrite -n $sockname QUIT
        p3add $+(%SID,.state)) 99
      }
    }
    elseif ($p3get($+(%SID,.state)) == 5) {
      p3add $+(%SID,.write)) 1
    }
    elseif ($p3get($+(%SID,.state)) == 6) {
      if ($p3get($+(%SID,.dele)) < $p3get($+(%SID,.num))) {
        p3add $+(%SID,.dele)) $calc($p3get($+(%SID,.dele)) + 1)
        sockwrite -n $sockname DELE $p3get($+(%SID,.dele))
      }
      else {
        sockwrite -n $sockname QUIT
        p3add $+(%SID,.state)) 99
      }
    }
    elseif ($p3get($+(%SID,.state)) == 99) {
      sockclose $sockname
      echo 3 -a POP3 $p3get($+(%SID,.name)) * Disconnected from server
      p3wdel $+(%SID,.*)
    }
  }
  elseif ($p3get($+(%SID,.state)) == 5) {
    if ($1- == .) {
      .rename $+($p3get($+(%SID,.path)),%SID,.tmp) $+($p3get($+(%SID,.path)),%SID,.txt)
      echo 7 -a POP3 $p3get($+(%SID,.name)) * Saved new message as $+($p3get($+(%SID,.path)),%SID,.txt)
      p3add $+(%SID,.write)) 0
      if ($p3get($+(%SID,.count)) < $p3get($+(%SID,.num))) {
        p3add $+(%SID,.count)) $calc($p3get($+(%SID,.count)) + 1)
        sockwrite -n $sockname RETR $p3get($+(%SID,.count))
      }
      else {
        p3add $+(%SID,.dele)) 1
        sockwrite -n $sockname DELE 1
        p3add $+(%SID,.state)) 6
      }
    }
    else {
      write $+($p3get($+(%SID,.path)),%SID,.tmp) $iif($1,$1-,$crlf)
    }
  }
}

alias p3add hadd -m pop3 $1 $2-
alias p3get return $hget(pop3,$1)
alias p3wdel hdel -w pop3 $1-

alias getmailcleanup {
  if ($sock($1)) {
    sockwrite -n $1 QUIT
    sockclose $1
  }
  if ($p3get($+($1,.name)) != $null) echo 3 -a POP3 $p3get($+($1,.name)) * Disconnected from server
  if ($hget(pop3)) p3wdel $1




Sample aliases /dogetmail and /dochkmail demonstrate how to call the /getmail alias. /dochkmail shows only checking whether new messages exist, and /dogetmail shows checking for new messages and downloading and deleting those messages. Downloaded messages are saved in the path that you specify for that connection.

This code has been tested on a non-SSL POP3 server. Theoretically, it can also connect to SSL POP3 servers, though I cannot test that functionality because I don't have SSL installed in my mIRC. To enable SSL, add the -e switch to the /getmail command. Example:

Code:

/getmail -e EMAIL_3 smtp.server.com 995 username password $true email\third



Let me know about any errors. Also, let me know if it works on SSL servers.

-genius_at_work

Joined: Oct 2007
Posts: 214
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
All I have to say is WoW!,

your work is really quite impressive.

Awesome job and great work!.

PS. Your code does not have any errors in it and works for me on a non SSL POP Server.

Great Job!, thanks so much again.

Cheers,

Jay




Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I forgot to mention that the POP3 code is multi-call capable. You can call /getmail several times without having to worry about the calls interfering with each other. Example:

Code:

alias multimail {
  getmail EMAIL_1 smtp.first.com 110 myusername MyPassword $true email\first\
  getmail EMAIL_2 smtp.second.com 110 my.email@second.com ThisPassword $false email\second\
}



-genius_at_work

Joined: Sep 2008
Posts: 62
_
Babel fish
Offline
Babel fish
_
Joined: Sep 2008
Posts: 62
For working TLS support, you have to issue a request to use it in both POP3/SMTP. Here are the rfc's for POP3 and SMTP.

Good work btw.

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Here is a sample of a connection attempt to gmail's smtp server:


(Open non-SSL connection to smtp.gmail.com:587)
220 mx.google.com ESMTP t1sm528266poh.2
EHLO localhost
250-mx.google.com at your service, [24.67.129.81]
250-SIZE 35651584
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES

STARTTLS
220 2.0.0 Ready to start TLS
EHLO localhost
(Server disconnects immediately)

Everything up to the last 220 matches the RFC you posted, but I can't find any documentation regarding this part:

S: <waits for connection on TCP port 25>
C: <opens connection>
S: 220 mail.imc.org SMTP service ready
C: EHLO mail.ietf.org
S: 250-mail.imc.org offers a warm hug of welcome
S: 250 STARTTLS
C: STARTTLS
S: 220 Go ahead

C: <starts TLS negotiation>
C & S: <negotiate a TLS session>
C & S: <check result of negotiation>


If anyone can point me to the information to complete the TLS negotiation, I should be able to get my code working.

-genius_at_work

Joined: Sep 2008
Posts: 62
_
Babel fish
Offline
Babel fish
_
Joined: Sep 2008
Posts: 62
I can't find any information on the handshake, other than direct C code for the SSL/TLS protocol itself. But I'm willing to bet the OpenSSL library handles the handshake portion internally (verifying certificates), and you only need to use a SSL socket to get it to work.

Code:
After receiving a 220 response to a STARTTLS command, the client MUST
   start the TLS negotiation before giving any other SMTP commands.  If,
   after having issued the STARTTLS command, the client finds out that
   some failure prevents it from actually starting a TLS handshake, then
   it SHOULD abort the connection.


I don't see any outlined sections explaining if the server is responsible for verifying a TLS handshake, but it's probably standard practice for the server to abort the connection if there is going to be a problem with the handshake.

An earlier post you a said you don't have the SSL libraries.. to simplify things, someone has the DLLs zipped ready to be extracted to $mircdir over here


Last edited by _Memo; 20/11/08 03:11 AM.
Joined: Nov 2008
Posts: 2
D
Bowl of petunias
Offline
Bowl of petunias
D
Joined: Nov 2008
Posts: 2
I have been working on the same thing currently I have a work around with sending to gmail but it requires installing an SMTP server on my system, socket connecting to it and having in the RCPT TO:Whoever@gmail.com
and then setting a filter inside gmail to check for the subject to be IRC Text Message and From to be from what ever I setup in the MAIL FROM:.

I am using my own custom script to connect and currently I have found a way to use MS-DOS to connect correctly to gmail and send an email log file shown below.

I am working on a way for a TLS connection through mSL code currently and will keep you updated on my progress (just started all of this about 25 hours ago and have spent about 18 or so hours total towards learning SMTP protocol, AUTH, TLS connections, and writing my script.



This is the command entered with openssl installed in C:\Windows\System32
Code:
C:\Documents and Settings\User>openssl s_client -connect smtp.googlemail.com:25 -starttls smtp -crlf

*Notes for command above
s_client - Used to establish that you are the client
-connect - Connect to proceeding server:port
-starttls - Automatically start a TLS connection simliar to a telnet connection
smtp - telling the -starttls that this is a smtp server
-crlf - Changes normal LF or linefeed (next line) into CR LF or Carriage return Line Feed (which is required for SMTP)

*Note S> = server notice C> = Client typed. Added Blank Lines for easier Readability. Only S> and C> are actual communication all * are notes. Edit - All commands sent to openSSL should be lowercase. If you try and use an uppercase R or Q it will not send the command but be interpreted as either renegotiate or quite respectively.
Code:
S>250-mx.google.com at your service, [71.53.76.253]
*servers Welcome after the TLS handshake

S>250-SIZE 35651584

S>250-8BITMIME

S>250-STARTTLS

S>250-ENHANCEDSTATUSCODES

S>250 PIPELINING
*servers modes available

C>ehlo Demonlord.Haxx
*ehlo to tell server that we want enhanced SMTP

S>250-mx.google.com at your service, [71.53.76.253]

S>250-SIZE 35651584

S>250-8BITMIME

S>250-AUTH LOGIN PLAIN

S>250-ENHANCEDSTATUSCODES

S>250 PIPELINING
*New server modes presented

C>auth login
*Tell the server we want to login

S>334 VXNlcm5hbWU6
*Server asking for username VXNlcm5hbWU6 stands for username in *Base64

C>RXhhbXBsZQ==
*Client Username changed to Base 64 in this case it means Example

S>334 UGFzc3dvcmQ6
*Server Asking for password UGFzc3dvcmQ6 = Password in base 64

C>R21haWw=
*Client Password in Base 64 in this case it means Gmail

S>235 2.7.0 Accepted
*Server accepts Login

C>mail from:<fad2007@gmail.com> auth=fad2007@gmail.com
*You *MUST* add the AUTH like this to make it work correctly!

S>250 2.1.0 OK 28sm2010271qbw.11

C>rcpt to:<relayirc@gmail.com>

S>250 2.1.5 OK 28sm2010271qbw.11

C>data

S>354  Go ahead 28sm2010271qbw.11

C>from:irc@irc.com

C>to:relayirc@gmail.com

C>subject:text

C>
*MUST INCLUDE BLANK LINE THERE

C>Test123 123 12345

C>
*MUST INCLUDE BLANK LINE THERE

C>.
*PERIOD ENDS EMAIL

S>250 2.0.0 OK 1227251631 28sm2010271qbw.11
*Message Being sent

C>QUIT
*Ends openssl connection

S>DONE
*openssl connection closed successfully

Last edited by Demonlord; 21/11/08 08:07 AM.
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
I'm looking at your log file there, and I'm noticing something weird. You said that the log starts after the TLS connection is already established, but I read in one of the RFCs that the server MUST NOT send 250-STARTTLS if the TLS connection already exists. I wonder if gmail follows that portion of the SMTP protocol properly, or if the google programmers have created their own gSMTP protocol.... I don't have access to any other TLS-enabled SMTP servers, but it might be interesting to try the connection on one that isn't gmail.

-genius_at_work

Joined: Nov 2008
Posts: 2
D
Bowl of petunias
Offline
Bowl of petunias
D
Joined: Nov 2008
Posts: 2
The 250 - STARTTLS is just a server option, it is listing the available functions of the server if you actually respond using that it will say that the TLS session is already started.

Right now I am working with VB to try and write a mIRC dll that when you can use to send the variables
%emailSMTPserv
%emailSMTPport
%emailAUTHlogin
%emailAUTHpass
%emailMailFrom
%emailRcptTo
%emailTo
%emailFrom
%emailSubject
%emailMessage
to it using the /dll command and it will interface with the OpenSSL dll's to open the connection using TLS automatically and then have it send the email. I am not very good with VB so this may take me a bit of time. But I am thinking its about the only way to do a secure connection to a SMTP server.

I already tried having mIRC write a .bat file and running it but as soon as the OpenSSL command is run it doesn't parse any other commands until the OpenSSL ends. Also using the -e switch with sockopen doesn't do the handshake either so don't think its possible using sock mSL commands.

If the DLL doesn't work out the only other way I can see is possibly using Stunnel to negotiate the TLS handshake.

Last edited by Demonlord; 22/11/08 02:26 AM.
Joined: Aug 2006
Posts: 183
T
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
GaW: I also get this error when using gmail.

Quote:
[11/24/08] [08:44:50] ** ERROR: 530 5.7.0 Must issue a STARTTLS command first. 4sm4604398yxd.2


Edit: Apparently, I quoted something that was said above. My bad. You can pretty much ignore this post. smile

Edit2: I realize this is a bit out of left field, but I'm able to send emails from my hotmail account to my phone (I assume most phones that can get text messages can also get emails from hotmail). Wouldn't it be easier to just make a script that accesses your hotmail account and sends the email right to your phone?

I'm not terribly good with sockets, and I know hotmail has you jump through some hoops to do this kind of thing. However, I suspect it would be easier for someone who knows what they're doing to do tha instead of fooling around with TLS

Last edited by Thrull; 24/11/08 02:47 PM.

Yar
Joined: Oct 2007
Posts: 214
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Oct 2007
Posts: 214
Hello,

Using the SMTP code provided to send email,

Is there a way to send html email instead of just plain text.

I was trying to play around with it for a bit, but my results are either a blank screen or plain text.

I am just wondering if its possible

Any ideas?

Cheers,

Jay

Joined: Sep 2008
Posts: 62
_
Babel fish
Offline
Babel fish
_
Joined: Sep 2008
Posts: 62
Seeing how the OP came here wanting help for Gmail, and Gmail being the only popular web email service out there that offers SMTP/POP3 access (for free), I'd say the foolish thing would be to bother tackling Hotmail.

Since you're not too familiar with sockets, I wonder why you would suggest using sockets since that would be the hardest way of approaching a javascript enriched email service? The easiest method here would be just to use nHTML imo.


Joined: Aug 2006
Posts: 183
T
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
Originally Posted By: _Memo
Seeing how the OP came here wanting help for Gmail, and Gmail being the only popular web email service out there that offers SMTP/POP3 access (for free), I'd say the foolish thing would be to bother tackling Hotmail.


Yes, I'll refrain from posting ideas from now on. What WAS I thinking? Its not like I was trying to be helpful or anything. After all, since the gmail thing is working so well as it is, why would we need other ideas?

Quote:
Since you're not too familiar with sockets, I wonder why you would suggest using sockets since that would be the hardest way of approaching a javascript enriched email service? The easiest method here would be just to use nHTML imo.


Well, as far as I know, Mirc can't use nHTML. I suggested using sockets because, well, its possible and your way isn't. Again, I thought it would be wise to try do have an idea that might work as opposed to one that wouldn't. I'll refrain from doing that in the future as well.


Yar
Joined: Sep 2008
Posts: 62
_
Babel fish
Offline
Babel fish
_
Joined: Sep 2008
Posts: 62
nHTML is a DLL written specifically for mIRC, which as far as I know, still works. Here is the link to a modified version which quite a few scripters use.

From Hotmail.com --
Quote:
Windows Live ID requires JavaScript to sign in.


To use hotmail for sending email, sockets alone wouldn't suffice. The method this thread has been talking about uses a method where socket scripting alone works, however theres been a bit of a snag with the TLS involved. Your suggestion wasn't ridiculous, just not practical in this situation. Using Hotmail via nHTML would be possible if one chose to go that route, though.

I believe using AIM would be the best medium for sending text messages, however. Because not all carriers support phonenumber@carrier.tld, and that introduces a limitation. AIM however uses SMS so it's compatible with all carriers. I'm not sure if TOC allows sending mobile messages, but Oscar for sure does.

Joined: Aug 2006
Posts: 183
T
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 183
I tried using hotpop.com instead of gmail.

It seems to work for the first few steps, then it just stops doing anything. This is what I see with debug on:

Quote:
[11/28/08] [16:53:16] 220 -> EHLO (Introduce ourselves)
[11/28/08] [16:53:16] 250 -> AUTH LOGIN (Begin authentication)
[11/28/08] [16:53:16] 334 -> c2xpbXRocnVsbHhASG90UE9QLmNvbQ== (Send Base64 encoded username)
[11/28/08] [16:53:16] 334 -> VGh1bmRlcjE= (Send Base64 encoded password)
[11/28/08] [16:53:16] 250 -> MAIL (Auth OK; Specify FROM address)
[11/28/08] [16:53:16] 250 -> RCPT (Specify TO address)


It looks like the first few steps are handled fine, but after that it simply stops.


Yar
Page 2 of 2 1 2

Link Copied to Clipboard