Send an Email with mIRC (BACK END)
Platform: mIRC
Published Mar 05, 2010
Updated Apr 28, 2012
************ THIS REQUIRES OPENSSL IF USING SSL SMTP SERVER ****************
More info here:
http://www.mirc.com/ssl.html
****
Also Note: Have had issues with mIRC 7.1 so please update to the latest
** You must modify the server, port, username, and password in the modification section ********
Complete Rewrite from Original, it now uses SMTP Authentication and can use SSL.
I have tested this with GMail, it works great, should work with any SSL/Normal SMTP Authentication server.
*** Note on Non-SSL servers, the password is pretty much sent as plain text. If you are not using SSL the traffic can easily be sniffed. Your username and password will be visible, use at your own risk. SSL should be pretty secure.
**** Also, username and password are stored as plain text. Unfortunately, this is a limitation of mIRC and SMTP ****
Version Change Log:
V 1.0.0 -- Initial Release (Mar 04, 2010)
V 1.1.0 -- (Aug 12, 2011)
* Added SSL support
* Changed to Authentication
* TESTED WITH GMAIL
* No need for NSlookup anymore
V 1.2.0 -- (Oct 08,2011)
* Fixed email.error alias typeo
You can find more about smtp
here
Example Below:
; +-+-+-+-+-+-+-+-+-+-+-+-+-+
; + Send Email With mIRC +
; + Author: Imrac +
; + Version: 1.2.0 +
; + Date: Oct 8, 2011 +
; +-+-+-+-+-+-+-+-+-+-+-+-+-+
;Version Change Log:
/*
V 1.0.0 -- Initial Release (Mar 04, 2010)
V 1.1.0 -- (Aug 12, 2011)
* Added SSL support
* Changed to Authentication
* TESTED WITH GMAIL
* No need for NSlookup anymore
V 1.2.0 -- (Oct 08,2011)
* Fixed email.error alias typeo
*/
; /////////////////////////// USEAGE ///////////////////////////////////
; Step 1: Call /email.start (You may use debug as paramter 1 to display useful info)
; Step 2: Call /email.to/from/subject/body (doesn't matter order, as long as its all their)
; Step 3: Call /email.send (attempts to send the email, you can specify an error alias
; it will be called if an error occurs with info )
; Note: Body can be called multiple times with or without content ($crlf is sent if blank)
; /email.start [debug]
; /email.from <email_address> [Real Name]
; /email.to <email_address> [Real Name]
; /email.subject <subject>
; /email.body [your body here] Can be called multiple times
; /email.send [callback]
; callback alias will be blank if success, or return the error.!
; ----------------- MODIFY HERE -------------------------------
alias -l _email.server { return smtp.gmail.com }
alias -l _email.port { return 465 }
alias -l _email.ssl { return $true }
alias -l _email.username { return email@gmail.com }
alias -l _email.password { return xxxxxxxxxx }
; ------------------ END MODIFY -------------------------------
alias email.start {
if ($hget(email)) { hfree email }
hadd -m email send_attempt false
if ($1 == debug) { hadd -m email debug true }
}
alias email.to {
if ($regex($1,/^(.*?)@(.*?)$/)) {
hadd -m email to_full $1
hadd -m email to_host $regml(2)
hadd -m email to_name $2-
}
}
alias email.from {
if ($regex($1,/^(.*?)@(.*?)$/)) {
hadd -m email from_full $1
hadd -m email from_host $regml(2)
hadd -m email from_name $2-
}
}
alias email.subject { hadd -m email subject $1- }
alias email.body { hadd -m email body_ $+ $calc($hfind(email,body_*,0,w) + 1) $1- }
alias email.send {
hadd -m email error $1
e.connect
.timeremail 1 10 sockclose S_EMAIL
}
alias -l e.connect {
if (!$sock(email)) { sockopen $iif($_email.ssl,-e,) S_EMAIL $_email.server $_email.port }
else { e.error Socket already in use }
}
alias -l e.write {
if ($hget(email,debug)) { echo -a C: $iif($1 == -omit, <Omitted Output>, $1-) }
sockwrite -n S_EMAIL $iif($1 == -omit, $2-, $1-)
}
alias -l e.error { if ($hget(email,error)) $v1 $1- }
alias -l e.finished { if ($hget(email,error)) $v1 }
on *:sockopen:S_EMAIL:{
if ($sockerr) { e.error Unable to open socket }
else { hadd -m email step 1 }
}
on *:SOCKREAD:S_EMAIL:{
IF ($sockerr) { e.error Error reading socket }
var %read
var %step $hget(email,step)
sockread %read
if ($hget(email,debug)) { echo -a S: %read }
if ( ($regex(%read,/^(\d\d\d)([ -])(.*)$/)) && ($regml(2) != -) ) {
var %code $regml(1)
var %response $regml(3)
if ((%step == 1) && (%code == 220)) { e.write EHLO | hinc email step 1 }
elseif ((%step == 2) && (%code == 250)) { e.write AUTH LOGIN | hinc email step 1 }
elseif ((%step == 3) && (%code == 334) && (%response == VXNlcm5hbWU6)) { e.write -omit $encode($_email.username,m) | hinc email step 1 }
elseif ((%step == 4) && (%code == 334) && (%response == UGFzc3dvcmQ6)) { e.write -omit $encode($_email.password,m) | hinc email step 1 }
elseif ((%step == 5) && (%code == 235)) { e.write MAIL FROM: $+(<,$hget(email,from_full),>) | hinc email step 1 }
elseif ((%step == 6) && (%code == 250)) { e.write RCPT TO: $+(<,$hget(email,to_full),>) | hinc email step 1 }
elseif ((%step == 7) && (%code == 250)) { e.write DATA | hinc email step 1 }
elseif ((%step == 8) && (%code == 354)) {
e.write From: $iif($hget(email,from_name),$qt($v1),) $+(<,$hget(email,from_full),>)
e.write To: $iif($hget(email,to_name),$qt($v1),) $+(<,$hget(email,to_full),>)
e.write Subject: $hget(email,subject)
e.write
var %total = $hfind(email,body_*,0,w), %i = 1
while (%i <= %total) { e.write $hget(email,$+(body_,%i)) | inc %i 1 }
e.write .
hinc email step 1
}
elseif ((%step == 9) && (%code == 250)) { e.write QUIT | hinc email step 1 }
elseif ((%step == 10) && (%code == 221)) { e.finished }
else { e.error %read }
}
}
on *:SOCKCLOSE:S_EMAIL:{ .timeremail off }