abhi2011 Posted May 7, 2012 Author Share Posted May 7, 2012 This is my 4th tutorial and most probs the best one so far. I give credits to GoldSide for actually making one that stores the email ID in account data(though email isn't sent) and to myself.Required tutorials = http://www.touchofdeathforums.com/smf2/index.php/topic,78011.0.htmlif you have done the tutorial please continue.The email send using gmail's SMTP. How it works is that when the you register there will be a small lag with the server meaning that an email is being sent. (Affects everyone for about 10s.) The server will send an email to the email address specified by the player with the gmail ID the server owner has specified.SERVER SIDEReplace the handleNewAccount in modhandle data with```Private Sub HandleNewAccount(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer Dim Name As String Dim Password As String Dim Email As String Dim i As Long Dim n As Long Dim oSmtp As New EASendMailObjLib.Mail If Not IsPlaying(Index) Then If Not IsLoggedIn(Index) Then Set Buffer = New clsBuffer Buffer.WriteBytes Data() ' Get the data Name = Buffer.ReadString Password = Buffer.ReadString Email = Buffer.ReadString ' Prevent hacking If Len(Trim$(Name)) < 3 Or Len(Trim$(Password)) < 3 Or Len(Trim$(Email)) < 3 Then Call AlertMsg(Index, "Your account name must be between 3 and 12 characters long. Your password must be between 3 and 20 characters long.") Exit Sub End If ' Prevent hacking If Len(Trim$(Name)) > ACCOUNT_LENGTH Or Len(Trim$(Password)) > NAME_LENGTH Then Call AlertMsg(Index, "Your account name must be between 3 and 12 characters long. Your password must be between 3 and 20 characters long.") Exit Sub End If ' Prevent hacking For i = 1 To Len(Name) n = AscW(Mid$(Name, i, 1)) If Not isNameLegal(n) Then Call AlertMsg(Index, "Invalid name, only letters, numbers, spaces, and _ allowed in names.") Exit Sub End If Next 'send email oSmtp.LicenseCode = "TryIt" ' Set your Gmail email address oSmtp.FromAddr = "[email protected]" ' Add recipient email address oSmtp.AddRecipientEx Email, 0 ' Set email subject oSmtp.Subject = "Account Creation in " & Options.Game_Name ' Set email body oSmtp.BodyText = "An account has been recently created in our game " & Options.Game_Name & "." & vbCrLf & "Your login details are," & vbCrLf & "Username = " & Name & vbCrLf & "Password = " & Password & vbCrLf & "If this wasn't you please reply to this email requesting an account delete" & vbCrLf & "Thank You," & vbCrLf & Options.Game_Name & "Staff" ' Gmail SMTP server address oSmtp.ServerAddr = "smtp.gmail.com" ' If you want to use direct SSL 465 port, ' Please add this line, otherwise TLS will be used. ' oSmtp.ServerPort = 465 ' detect SSL/TLS automatically oSmtp.SSL_init ' Gmail user authentication should use your ' Gmail email address as the user name. ' For example: your email is "[email protected]", then the user should be "[email protected]" oSmtp.UserName = "[email protected]" oSmtp.Password = "password" If oSmtp.SendMail() = 0 Then ' Check to see if account already exists If Not AccountExist(Name) Then Call AddAccount(Index, Name, Password) Call TextAdd("Account " & Name & " has been created.") Call AddLog("Account " & Name & " has been created.", PLAYER_LOG) ' Load the player Call LoadPlayer(Index, Name) ' Check if character data has been created If LenB(Trim$(Player(Index).Name)) > 0 Then ' we have a char! HandleUseChar Index Else ' send new char shit If Not IsPlaying(Index) Then Call SendNewCharClasses(Index) End If End If ' Show the player up on the socket status Call AddLog(GetPlayerLogin(Index) & " has logged in from " & GetPlayerIP(Index) & ".", PLAYER_LOG) Call TextAdd(GetPlayerLogin(Index) & " has logged in from " & GetPlayerIP(Index) & ".") Else Call AlertMsg(Index, "Sorry, that account name is already taken!") End If Set Buffer = Nothing End If End IfEnd IfEnd Sub```Then download this file [http://www.emailarchitect.net/webapp/download/easendmail.exe](ftp://www.emailarchitect.net/webapp/download/easendmail.exe)Then in Menu Bar go to Project > References and find "EASendMailObj ActiveX Object", to add the reference. ![](http://www.emailarchitect.net/img/vb_easendmail.jpg)Hope you like it and it is tested with my 2 email id's.Also please replace "[email protected]" & "Passowrd with the appropriate stuff. I also think it will work with email id's given by website hosters as long as it's SMTP. Link to comment Share on other sites More sharing options...
tslusny Posted May 7, 2012 Share Posted May 7, 2012 so do this client side and the wont be any server lag Link to comment Share on other sites More sharing options...
tslusny Posted May 7, 2012 Share Posted May 7, 2012 just replace email id viariable by txtREmail.text Link to comment Share on other sites More sharing options...
abhi2011 Posted May 7, 2012 Author Share Posted May 7, 2012 @tslusny:> so do this client side and the wont be any server lagNo I don't think so. But the best way would be to make a packet data sent from server to client telling to do the call the email send. That way would be the best making sure that if registered it will be sent! Link to comment Share on other sites More sharing options...
abhi2011 Posted May 7, 2012 Author Share Posted May 7, 2012 @tslusny:> just replace email id viariable by txtREmail.texthuh? Link to comment Share on other sites More sharing options...
zomb88 Posted May 7, 2012 Share Posted May 7, 2012 This looks ok and looks like it will do its purpose.But as tslusny said….Perform the send email action client side not server side. That would not add to any server stress. Link to comment Share on other sites More sharing options...
tslusny Posted May 7, 2012 Share Posted May 7, 2012 i done it i make tutorial for client side in few secs :D Link to comment Share on other sites More sharing options...
abhi2011 Posted May 7, 2012 Author Share Posted May 7, 2012 ~~Okay, I'll do it.~~Ah I couldn't do it in time. I lost power so my computer crashed. And so I couldn't do it. Anyways. It doesn't matter. requesting delete! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now