RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Simple Email Registration

Orbit Storm

Sorceror
Is there a method to changing the string that is sent to users via email? I'd like to customize mine a bit, and advise them of how to change their email in the future (if they must), since I have merged this system with my MOTD; as well as giving them a heads up on just what the emails are used for.

I know I'm able to edit the string in EmailRegisterGump, but there's some weird syntax in the line that I'm not familiar with. (i.e. the + c +)
 

hungry4knowhow

Sorceror
Hey dazed, the fix for the system not working from jump off is you have to enable it...*DUH* I know right.

In emailclient.cs look for:
Code:
 public class RegisterEmailClient
    {
        public static bool Enabled = false; // Is this system enabled?

change false to true.

God I feel stupid sometimes. Anyway, hope that works out for you too :)
 

Evanonian

Sorceror
Alex, I absolutely love this script! I just installed it on my Test Server and it's working like a charm however, I do have a suggestion. It would be cool if you had the option to email individual users. If I ever banned a player it would be nice to be able to send them an email telling them why and how long they're banned for (etc.) Other than that, GREAT script thanks for sharing! :)
 

Evanonian

Sorceror
Is there a method to changing the string that is sent to users via email? I'd like to customize mine a bit, and advise them of how to change their email in the future (if they must), since I have merged this system with my MOTD; as well as giving them a heads up on just what the emails are used for.

I know I'm able to edit the string in EmailRegisterGump, but there's some weird syntax in the line that I'm not familiar with. (i.e. the + c +)

Orbit, if you look here:
Code:
 string msg = "Thank you for submiting your email, you must use the 10 character long confirmation code below to confirm you got this email \n \n" + c + "\n \n To use this confirmation code you must type \"[auth\" in game and enter the code exactly as it appears here in the email into the text box provided. \n \n" + "Thank You"; ;

This is my modified string. the "+ c +" I believe is responsible for generating the 10 digit code. the "\n \n" I believe are spaces and such and then the + is just adding the "Thank You" to the string.

So you could easily do "This is my message \n \n" + c + "\n \n There are many like it \"[auth\" but this is my own. \n \n" + "Thank You"; ;

I hope this helps a little, if you need help modifying any of the strings just post them here and I'll help.
 

alchimysty

Wanderer
Thanks for the insight into this Ixtabay...i'm a bit confused by this code however. Is it all one line of text?

for example: certmgr -ssl -m smtps://smtp.gmail.com:465 mozroots --import --ask-remove --machine

or is the mozroots part something else? I tried single line and both lines from the command shell and it just brings up the
the cert manager snap in.

-Alch



Here is the solution to the Gmail problem. You can use gmail or google apps (free google email for you domain name) using this method. First, the problem is that to send through gmail, you must use SSL, which requires a trusted certificate. If you don't have it, connection will be refused.
Simple to fix, open term, and...

Code:
certmgr -ssl -m smtps://smtp.gmail.com:465
 
mozroots --import --ask-remove --machine

answer [y] to questions.
 

MrNice

Squire
Well love the idea but there is a crash

RunUO Version 2.2, Build 4643.24376
Operating System: Microsoft Windows NT 6.1.7601 Service Pack 1
.NET Framework: 2.0.50727.5420
Time: 11/6/2012 11:01:41 AM
Mobiles: 21346
Items: 120522
Exception:
System.FormatException: The specified string is not in the form required for an e-mail address.
at System.Net.Mime.MailBnfHelper.ReadMailAddress(String data, Int32& offset, String& displayName)
at System.Net.Mail.MailAddressCollection.ParseValue(String addresses)
at Server.Misc.RegisterEmailClient.SendSingal(Object e)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

very easy to re-create
in the email box that pops up type in whatever@@gmail.com
then confirm it as whatever@@gmail.com because its not in a proper email format it crashes

I am using the latest SVN and would like to get this to work! Any help would be great! thanks again.
 

Evanonian

Sorceror
I've been using this script for awhile now and no one has ever made this happen, this is a good catch because it's a disaster waiting to happen. I just reproduced this crash on my Test Server as well. I have a feeling it's right here.

In EmailRegisterGump.cs
Code:
public override void OnResponse(NetState sender, RelayInfo info)
{
            if (EmailHolder.Emails == null)
                EmailHolder.Emails = new Dictionary<string, string>();
            if (EmailHolder.Confirm == null)
                EmailHolder.Confirm = new Dictionary<string, string>();
            if (EmailHolder.Codes == null)
                EmailHolder.Codes = new Dictionary<string, string>();
 
Mobile from = sender.Mobile;
 
            switch (info.ButtonID)
            {
                case 0:
                    {
                        from.SendMessage("You will be asked again to register next login.");
                        break;
                    }
                case 1:
                    {
                        TextRelay relay = (TextRelay)info.GetTextEntry(2);
                        string txt1 = (string)relay.Text.Trim();
 
                        TextRelay relay2 = (TextRelay)info.GetTextEntry(3);
                        string txt2 = (string)relay2.Text.Trim();
 
                        if (ValidateEmail(txt1, txt2))
                        {
                            string c = CreateConFirmation();
 
                            Account acct = (Account)from.Account;
 
                            string test = (string)acct.Username;
 
                            string email = txt1;
 
                            if (!EmailHolder.Confirm.ContainsKey(test))
                            {
                                EmailHolder.Confirm.Add(test, txt1);
                                EmailHolder.Codes.Add(test, c);
                            }
                            else
                            {
                                EmailHolder.Confirm.Remove(test);
                                EmailHolder.Codes.Remove(test);
 
                                EmailHolder.Confirm.Add(test, txt1);
                                EmailHolder.Codes.Add(test, c);
                            }
 
                            string msg = "Thank you for submiting your email, you must use the 10 character long confirmation code below to confirm you got this email \n \n" + c + "\n \n To use this confirmation code you must type \"[auth\" in game and enter the code exactly as it appears here in the email into the text box provided. \n \n" + "Thank You"; ;
 
                            EmailEventArgs eea = new EmailEventArgs(true, null, email, "Email Registration", msg);
 
                            RegisterEmailClient.SendMail(eea);
                            from.SendMessage("You have been sent a confirmation code, it will expire when you next log out.");
                        }
                        else
                        {
                            from.SendMessage("You have not entered your email correctly, please try again.");
                            from.SendGump(new RegisterEmailGump());
                        }
 
                        break;
                    }
 
            }
}
}
}

I'm not the best at C# but it seems like there should be a check that makes sure the email entered is in the correct format i.e [email protected] and if it's not it will just return an error message. I'm curious how we could get this fixed as well.
 

MrNice

Squire
I think the error is in the way the email is saved if its in the wrong format. Everything points to EmailHandler.cs but not sure what to edit or where abouts the extra code needs to be added.
 

Evanonian

Sorceror
Okay so my friend fixed the crash issue.

He said it was using very basic testing to see if they put a valid email, so they could enter things that weren't valid emails but the server thought they were so when the server would try to send them it would crash. So he added validation that's a little more strict using this regex he found here. http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address

Here's the fix, in EmailRegisterGump.cs add/modify the following lines marked by Will's edits.
Code:
using System;
using System.Text.RegularExpressions; /* Will's Edit*/
using Server;
using Server.Commands;
using Server.Items;
using Server.Mobiles;
using System.Collections;
using System.Collections.Generic;
using Server.Accounting;
using Server.Network;
using Server.Misc;
using Server.Multis;
using Server.Targeting;
using Server.Gumps;
using System.Net.Mail;
using System.Threading;
using System.Net;
 
namespace Server.Gumps
{
public class RegisterEmailGump : Gump
{
        /* Begin Will's Edit*/
        private const string _emailRegex = @"^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
        /* End Will's Edit*/
 
public RegisterEmailGump() : base(0, 0)
{
Closable = true;
Dragable = true;
Resizable = false;
 
           AddBackground(47, 359, 409, 153, 3600);
AddLabel(204, 376, 1160, "Email Registration");
 
AddLabel(134, 404, 1153, "Email:");
            
AddAlphaRegion(180, 402, 255, 20);
AddTextEntry(180, 402, 255, 20, 33, 2, "" );
 
           AddLabel(80, 442, 1153, "Confirm Email:");
            
AddAlphaRegion(180, 439, 255, 20);
AddTextEntry(180, 439, 255, 20, 33, 3, "" );
 
           AddButton(135, 474, 4007, 4006, 1, GumpButtonType.Reply, 0);
           AddLabel(172, 476, 1153, "Submit");
}
 
        public bool ValidateEmail(string s, string s2)
        {
            /* Begin Will's Edit*/
            if (!Regex.IsMatch(s, _emailRegex))
            {
                return false;
            }
            /* End Will's Edit*/
 
            if (s == "" || s2 == "")
                return false;
 
            if (!s.Contains("@") || !s2.Contains("@"))
                return false;
 
            if (s != s2)
                return false;
 
            return true;
        }

I figured it was somewhere in the EmailRegisterGump.cs but I can't take credit for this edit.

UPDATE: It looks like you'll need to add those same changes to ChangeEmailGump.cs aswell :)
 

Evanonian

Sorceror
ah we must used dif versions of this, I use the most recent I do not have a ChangeEmail gump

Well MrNice,

It appears that you're right, I just downloaded the newest version. My version is from a few months ago, so you'd probably only need to change EmailRegisterGump.cs :) I'm gonna work with this new version considering I spent forever re-doing all the gumps for my server :p After I'm done I'll upload a version with the included fix and modified gump if you wish to use it you're welcome to. But for now you should be fine adding the fix to EmailRegisterGump.cs :)
 

MrNice

Squire
I applied the fixes you posted with the new system and so far I have not found a way to crash my shard :) So I would say its good to go but any changes you make I would love to see.
 

Evanonian

Sorceror
I applied the fixes you posted with the new system and so far I have not found a way to crash my shard :) So I would say its good to go but any changes you make I would love to see.

Yeah, I've looked at the script of the new system. It's exactly the same except he merged the email gumps. Instead of having seperate gumps for the initial EmailRegistration and then the ChangeEmail operation they both just use the EmailRegistrationGump so that fix should fix everything for you. :)
 

Erevan

Sorceror
has anyone had an issue with this system randomly not sending out emails? it seems it no longer works even though i never changed my email information.
 
Top