mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
Greetings.

Is there anyway to send an email via mIRC script using sockets, maybe using something like a hotmail pop3 smtp server to send the emails. I have a dialog ready made and wonder if anyone can offer any advise on how to go about this?

Kind Regards

Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
Here is a script i had in my mIRC folder.

Code:

alias sendmail {
  ;------ SET THESE VALUES THEN CALL /mail -----
  set %sndmail.fromaddress from@email.com
  set %sndmail.toaddress to@email.com
  set %sndmail.subject This is the subject
  set %sndmail.body This is the body
  var %host
  ;------
  ;
  set %sndmail.logfile $+(maillog.,$asctime(dd.mm.yyyy),.txt)
  set %sndmail.state 1
  if ($sock(sendmail)) sockclose sendmail
  ;write %sndmail.logfile # Connect Attempt to 
  sockopen sendmail smtp.server.com 25
}
;
on *:sockread:sendmail:{ 
  var %temptext
  sockread %temptext
  tokenize 32 %temptext

  ;write %sndmail.logfile $asctime(HH:nn:ss) -> $1- 
  if ((%sndmail.state == 1) && ($1 == 220)) {
    mailsockwrite HELO localhost
    echo 3 -a HELO
    inc %sndmail.state
  } 
  elseif ((%sndmail.state == 2) && ($1 == 250)) { 
    mailsockwrite MAIL From: $+ %sndmail.fromaddress
    echo 3 -a MAIL
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 3) && ($1 == 250)) { 
    mailsockwrite RCPT To: $+ %sndmail.toaddress 
    echo 3 -a RCPT
    inc %sndmail.state
  } 
  elseif ((%sndmail.state == 4) && ($1 == 250)) { 
    mailsockwrite DATA 
    echo 3 -a DATA
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 5) && ($1 == 354)) {
    mailsockwrite Subject: %sndmail.subject 
    mailsockwrite $crlf 
    mailsockwrite %sndmail.body 
    mailsockwrite . 
    echo 3 -a SEND
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 6) && ($1 == 250)) {
    mailsockwrite QUIT
    echo 3 -a QUIT
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 7) && ($1 == 221)) {
    sockclose $sockname
    echo 3 -a DONE
    unset %sndmail.*
  }
  elseif ((%sndmail.state < 0) && ($1 == 221)) {
    sockclose $sockname
    echo 4 -a DONE
    unset %sndmail.*
  }
  else {
    mailsockwrite QUIT
    echo 4 -a ERROR: $1-
    set %sndmail.state -1
  }
} 
;
alias mailsockwrite {
  sockwrite -n $sockname $1-
  ;write %sndmail.logfile $asctime(HH:nn:ss) <- $1-
}





-genius_at_work

Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
Hello genius_at_work

I tried having a bash at using this script and so far i have had no success. I set the values but for some reason the sockets not connecting?

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
You changed the most important line to an SMTP server that accepts your connections?

Code:
sockopen sendmail smtp.server.com 25

If not, change it.

If it still isn't working, show us some errors.

Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
i had changed it to
Code:
sockopen sendmail smtp.mail.yahoo.com 25


i am not getting any error messages. This works when done manually to another yahoo address, i was aiming for a similar result with the script.

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Ah. That's because yahoo requires you to authenticate. The simple conversation above doesn't include any authentication process. So, something like:

Code:
alias sendmail {
  ;------ SET THESE VALUES THEN CALL /mail -----
  set %sndmail.fromaddress from@email.com
  set %sndmail.toaddress to@email.com
  set %sndmail.subject This is the subject
  set %sndmail.body This is the body
  set %sndmail.user your.user@yahoo.com
  set %sndmail.pass yourpassword
  var %host
  ;------
  ;
  set %sndmail.logfile $+(maillog.,$asctime(dd.mm.yyyy),.txt)
  set %sndmail.state 1
  if ($sock(sendmail)) sockclose sendmail
  ;write %sndmail.logfile # Connect Attempt to 
  sockopen sendmail smtp.mail.yahoo.com 25
}
;
on *:sockread:sendmail:{ 
  var %temptext
  sockread %temptext
  tokenize 32 %temptext

  ;write %sndmail.logfile $asctime(HH:nn:ss) -> $1- 
  if ((%sndmail.state == 1) && ($1 == 220)) {
    mailsockwrite HELO localhost
    echo 3 -a HELO
    inc %sndmail.state
  } 
  elseif ((%sndmail.state == 2) && ($1 == 250)) { 
    mailsockwrite AUTH LOGIN
    echo 3 -a AUTH
    inc %sendmail.state
  }
  elseif ((%sndmail.state == 3) && ($1 == 334)) { 
    mailsockwrite $encode(%sndmail.user, m)
    echo 3 -a AUTH - Username
    inc %sendmail.state
  }
  elseif ((%sndmail.state == 4) && ($1 == 334)) { 
    mailsockwrite $encode(%sndmail.pass, m)
    echo 3 -a AUTH - Password
    inc %sendmail.state
  }
  elseif ((%sndmail.state == 5) && ($1 == 235)) { 
    mailsockwrite MAIL From: $+ %sndmail.fromaddress
    echo 3 -a MAIL
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 6) && ($1 == 250)) { 
    mailsockwrite RCPT To: $+ %sndmail.toaddress 
    echo 3 -a RCPT
    inc %sndmail.state
  } 
  elseif ((%sndmail.state == 7) && ($1 == 250)) { 
    mailsockwrite DATA 
    echo 3 -a DATA
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 8) && ($1 == 354)) {
    mailsockwrite Subject: %sndmail.subject 
    mailsockwrite $crlf 
    mailsockwrite %sndmail.body 
    mailsockwrite . 
    echo 3 -a SEND
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 9) && ($1 == 250)) {
    mailsockwrite QUIT
    echo 3 -a QUIT
    inc %sndmail.state
  }
  elseif ((%sndmail.state == 10) && ($1 == 221)) {
    sockclose $sockname
    echo 3 -a DONE
    unset %sndmail.*
  }
  elseif ((%sndmail.state < 0) && ($1 == 221)) {
    sockclose $sockname
    echo 4 -a DONE
    unset %sndmail.*
  }
  else {
    mailsockwrite QUIT
    echo 4 -a ERROR: $1-
    set %sndmail.state -1
  }
} 
;
alias mailsockwrite {
  sockwrite -n $sockname $1-
  ;write %sndmail.logfile $asctime(HH:nn:ss) <- $1-
}

(Note: untested)

Discussion:

There are multiple ways to do an auth request in SMTP. The simplest is the 'PLAIN' method. Unfortunately, this requires mIRC to encode a string with multiple $chr(0)'s in it. As you can't just throw this into an $encode(), this makes life a little difficult (Read: I dislike /bset!). The second simplest is the 'LOGIN' method, which literally asks you for your username and password in separate requests. As this doesn't require any stacking of values, it's more straight forward.

Although more complex and secure methods exist (i.e. 'CRAM-MD5', 'DIGEST-MD5' or 'GSSAPI'), Yahoo only supports LOGIN and PLAIN wink

Last edited by Bekar; 31/12/07 11:43 PM.
Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
Hello

After doing a lot of googling i found out that my ISP blocks port 25 and thats blocking my script from working. Is there any other way sockets can be used to send a message to an email address maybe going via a website or something. Please help?

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Did you try connecting to port 587 instead of 25?

Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
Hi
I can connect to yahoo and gmail on port 587, i have made those adjustments in the script and it now connects but is not sending any emails. Maybe i am filling those values in wrongly.
I also know that these mail servers only transfer mails to each other i.e a gmail server will only forward email to a gmail address. i am setting those values to keep within these rules. I also dont want to put a password in as i dont want users getting the password to my account.

I merely want to bounce mail of these mail servers without authentication, a manuel way of doing this would be start run and telnet://smtp.hotmail.com:25 that would go to a hotmail server and one can send emails to another hotmail account, as port 25 is blocked i can not use that one and hotmail does not offer port 587 for incoming connections. Google and yahoo does.

I am wondering if anyone can mod this script for me to make it work with any major email service provider that accepts incoming connections on 587, i would really appreciate it.

Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Nope.. At this point, it sounds too much like you're trying to send spam.

Joined: Mar 2007
Posts: 139
S
Solo1 Offline OP
Vogon poet
OP Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
Actually am not. that was quiet unjust. Its for a bug report dialog i have made so that users can send bug reports on my script. i paste the dialog code below. i wanted it to go to an email address i have set up for the script.

Code:
dialog irc_Bug {
  title "Irc Bug Reports"
  size -1 -1 398 240
  option pixels notheme
  edit "", 1, 55 27 289 126, autohs autovs multi vsbar
  box "Bug Reports", 2, 33 13 329 159
  text "", 3, 8 211 126 17, left
  button "Send", 4, 323 205 65 25
  button "Updates", 5, 8 192 79 14
}


Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
It would be much simpler to have a button/link on your dialog that opened the user's default mail program. You can /run the mailto: format to open the program. Example:

//run mailto:your@email.com?subject=bug report&body=omg a bug!


-genius_at_work


Link Copied to Clipboard