**** 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)
V 1.2.0 -- (Oct 08,2011)
You can find more about smtp here
Example Below:
; //////////////////////// EXAMPLE EMAIL /////////////////////////////////
alias email.test {
email.start debug
email.from email@gmail.com my name
email.to someone@somewhere.com asd
email.subject I am testing a new EMAIL sending thingy
email.body Thank you for signing up with $me on $network $+ . Please msg me with the following command to activate your account!:
email.body
email.body here is the stuff to activate!!
email.send my_erroralias
}
alias my_erroralias {
if ($0) echo -b $1-
else echo -b Mail Sent Complete!
}
; /////////////////////////// END EXAMPLE EMAIL ///////////////////////////////
; +-+-+-+-+-+-+-+-+-+-+-+-+-+
; + 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 }
If you follow the link http://www.google.com/support/accounts/bin/answer.py?answer=185833 it will show you how to generate an application specific password. As for attachments, that is beyond the scope of this snippet. I would have to add MIME support, which I am not going to do.
i have connection problems!, I have edit the _email.username and _email.password with mine and i have fill the correct address to the /email.test alias when i use it these errors appeared!
S: 220 mx.google.com ESMTP n18sm18872351fah.2
C: EHLO
S: 250-mx.google.com at your service, [178.146.104.43]
S: 250-SIZE 35882577
S: 250-8BITMIME
S: 250-AUTH LOGIN PLAIN XOAUTH
S: 250 ENHANCEDSTATUSCODES
C: AUTH LOGIN
S: 334 VXNlcm5hbWU6
C: <Omitted Output>
S: 334 UGFzc3dvcmQ6
C: <Omitted Output>
S: 535-5.7.1 Application-specific password required. Learn more at
S: 535 5.7.1 http://www.google.com/support/accounts/bin/answer.py?answer=185833 n18sm18872351fah.2
535 5.7.1 http://www.google.com/support/accounts/bin/answer.py?answer=185833 n18sm18872351fah.2
I gotz problem.
step = 2 220 mx.google.com ESMTP 7si1474535ibz.72
step = 3 250 mx.google.com at your service
step = 4 250 2.1.0 OK 7si1474535ibz.72
step = 5 250 2.1.5 OK 7si1474535ibz.72
step = 6 354 Go ahead 7si1474535ibz.72
sock sending: From: noreply@mywebsite.com
sock sending: To: "their name here" technogeek678@gmail.com
sock sending: Subject: some subject to send
sock sending Thank you for signing up with iBot on GeekShed. Please msg me with the following command to activate your account!:
sock sending
sock sending here is the stuff to activate!!
step = 7 250 2.0.0 OK 1283991021 7si1474535ibz.72
step = 8 221 2.0.0 closing connection 7si1474535ibz.72
Yeah we finished!!!!
Ok, good, it sent. Right?
No, I never got an email. Help?
AndrewFurr:
err woops, forgot to add /echo before output in the debug section of step 6. I updated the original post and should have corrected the issue.
As I don't have mIRC installed right now I cannot test the fix. Let me know if there is any more problems.
EDIT: Also, if you are still not receiving an email, check your spam folder. After that, if you are still not receiving an email PM me and we can try to debug why.
The problem with sending emails from a residential IP address, is a lot of times it will be blocked by either the MX server (Mail exchange server) or it could even be blocked by your ISP (thinking you have an infected computer sending out spam).
Shaneny:
The script should automagicly do a DNS lookup for a MX server, no setting needed.
I really need this snippet to let me know when there is a problem with my rpg bot on a "server computer." I remote desktop in to do my changes to code.
Thats what I received. It looked like it worked, but no email sent?
Of course I see that /sock is an uknown command, what should it be?
Any ideas?
Try email.test with your info and set email.start debug so it should look like this:
alias email.test {
email.start debug
email.from noreply@mywebsite.com my name here
email.to someone@gmail.com their name here
email.subject some subject to send
email.body Thank you for signing up with $me on $network $+ . Please msg me with the following command to activate your account!:
email.body
email.body here is the stuff to activate!!
email.send my_erroralias
}