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

i found same script in 2005 and here. but now i forgot how to setup. can you explain more clear please. because i really dont know which sc to where place.
 

Humpster

Wanderer
Code:
public static bool Enabled = true; // Is this system enabled?

        public static string ServerName = "xxxuo"; // Your server name here.

        public static string EmailServer = "http://www.xxxuo.com/squirrelmail/src/webmail.php"; // Your mail server here
        public static string User = "[email protected]"; // Your username here
        public static string Pass = "************"; // Your password here

        public static string YourAddress = "[email protected]"; // Your email address here, Or Shard name
        // Server will crash on start up if the adress is incorrectly formatted.

        public static SmtpClient client;
        public static MailMessage mm;

Is something wrong with this format? I tried hotmail it didn't work so I tried this
 

_FROG_

Wanderer
I have tried Gmail, Yahoo, and Hotmail and it is not writing to the XML or sending a confirmation code. Can someone post a working example of their set up or tell me what I have done wrong here?
This is what I have.
Code:
        public static bool Enabled = true; // Is this system enabled?

        public static string ServerName = "Shard Name"; // Your server name here.

        public static string EmailServer = "gmail.com"; // Your mail server here
        public static string User = "Email User"; // Your username here
        public static string Pass = "Emailpass"; // Your password here

        public static string YourAddress = "[email protected]"; // Your email address here, Or
 

Tresdni

Squire
For one, your EmailServer is not gmail.com

You need to enable pop3 on your gmail account, and use the server settings gmail gives you.

More than likely, it is going to be smtp.gmail.com
 

UO_Talon

Sorceror
Has anybody got this working properly with gmail? I've tried with my domain email and it still doesnt work?
 

Sythen

Sorceror
this never worked for me either
I'm using a 'smtp.east.cox.net'/'pop.east.cox.net' account and well it crashes my server every time.
 

Pure Insanity

Sorceror
Has anybody got this working properly with gmail? I've tried with my domain email and it still doesnt work?

You should try using pop.gmail.com instead of smtp.gmail.com also make sure pop is enabled for your gmail account or it won't work. If it doesn't work, you can try the smtp.gmail.com link instead and see if it works. Smtp requires authentication, don't think pop does. But both use ssl, smtp can also use tls though. Hope this helps.

Also, you're username should include the @gmail.com part at the end. Not just your gmail username.
 
You should try using pop.gmail.com instead of smtp.gmail.com also make sure pop is enabled for your gmail account or it won't work. If it doesn't work, you can try the smtp.gmail.com link instead and see if it works. Smtp requires authentication, don't think pop does. But both use ssl, smtp can also use tls though. Hope this helps.

Also, you're username should include the @gmail.com part at the end. Not just your gmail username.

Wow, misinformation alert! POP/IMAP are for recieving email. SMTP is for sending and relaying it. Different protocols for completely different purposes. The only thing he needs to do afaik is the username bit. The reason he needs to add the @gmail is because of google apps for gmail at custom domains. Also, the ports might need to eb changed, google apps uses nonstandard ports, not sure if vanilla gmail does or not. And gmail has forced ssl since early last year, so keep that in mind as well.

EDIT: ports for gmail are

POP: 995
IMAP: 993
SMTP: 465 OR 587
 

Phr3d13

Sorceror
Does anyone know what kinds of email servers work with this? or some more clear instructions or something?
 

seanandre

Sorceror
One thing I would like implimented into this system is the ability to set the port for the SMTP server. Most ISP's like mine do not allow you to SEND E-Mail through the regular port 25. Instead I have to change mine to port 80 in order to be able to send outgoing mail from my machine. I don't see a way to set the port in this script, and would very much like to use it for my shard, but I can't use it if i can't specify the port in which to send E-Mail from.

Thanks,
Sean
 

Johan Smith

Wanderer
Well i'm completely unsure since things are a bit murky but you can try adding :portnumber after the end of your email server name. For example: smtp.mailserver.com:80 or ideally the direct ip such as x.x.x.x:80 . As i mentioned i'm completely unsure but it's worth a try.

-Johan
 

Amazonia

Sorceror
Not working for me either. :/ I don't know what to put for Mail Server? If I use hotmail??? Like I'm just using my personal address for some tests, which is with Hotmail.
 

Ixtabay

Sorceror
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.

Next, change some code in EmailClient.cs

find...
Code:
        public static void Initialize()
        {
            if (Enabled)
            {
                client = new SmtpClient(EmailServer);
                client.Credentials = new NetworkCredential(User, Pass);
 
                mm = new MailMessage();
                mm.Subject = ServerName;
                mm.From = new MailAddress(YourAddress);
            }
        }

Change it to...

Code:
        public static void Initialize()
        {
            if (Enabled)
            {
                client = new SmtpClient
{
               Host = EmailServer,
               Port = 587,
               EnableSsl = true,
               DeliveryMethod = SmtpDeliveryMethod.Network,
               UseDefaultCredentials = false,
               Credentials = new NetworkCredential(User, Pass)
};
 
                mm = new MailMessage();
                mm.Subject = ServerName;
                mm.From = new MailAddress(YourAddress);
            }
        }

I plan to fix some other bugs and add features to this soon, because I want it on my shard too :) I'll be sure to share once it's production worthy.

Cheers,
Ixtabay
 

Ixtabay

Sorceror
Here is a MUCH better email verification

Edit EmailRegisterGump.cs

Add this to the top:

Code:
using System.Reflection;
using System.Text.RegularExpressions;

Now find this:
Code:
        public bool ValidateEmail(string s, string s2)
        {
            if (s == "" || s2 == "")
                return false;
 
            if (!s.Contains("@") || !s2.Contains("@"))
                return false;
 
            if (s != s2)
                return false;
 
            return true;
        }

Replace with this:

Code:
        public static bool ValidateEmail(string inputEmail, string inputEmail2)
        {
            if (inputEmail == "" || inputEmail2 == "") // are they blank?
                return false;
 
            if (inputEmail != inputEmail2) // do they match?
                return false;
 
            if( inputEmail == null || inputEmail.Length == 0 ) // is null or zero length?
                return false;
       
            const string expression = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                                    @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                                    @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
       
            Regex regex = new Regex(expression);
            return regex.IsMatch(inputEmail); // Does this email look legit?
        }
 

Pure Insanity

Sorceror
Why not simply use System.Net.Mail and convert the string to a MailAddress to see if it is valid. You then could queuery the server even and see if it is an active/real address. Regex is a bit slow, but this may not be much faster.
 

Ixtabay

Sorceror
Even if you did, you would probably still want to use regex to check the email format. I actually considered checking the domain, but was reluctant to add it without more controls in place. Until some controls are put in, a scripter could put serious load on the server with the form. I am planning to rewrite this and may release it with a domain check. In the mean time, if you want you can use something like this:

Code:
        public static bool ValidateEmail(string inputEmail, string inputEmail2)
        {
            if (inputEmail == "" || inputEmail2 == "") // are they blank?
                return false;
 
            if (inputEmail != inputEmail2) // do they match?
                return false;
 
            if( inputEmail == null || inputEmail.Length == 0 ) // is null or zero length?
                return false;
 
            strIn = Regex.Replace(inputEmail, @"(@)(.+)$", this.DomainMapper); // grab the domain name
            if (invalid)
                return false;
   
            const string expression = @"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                                    @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                                    @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";
   
            Regex regex = new Regex(expression);
            return regex.IsMatch(inputEmail); // Does this email look legit?
        }
        private string DomainMapper(Match match)
        {
            IdnMapping idn = new IdnMapping();
            string domainName = match.Groups[2].Value;
            try {
                domainName = idn.GetAscii(domainName);
                }
            catch (ArgumentException) {
            invalid = true;   
        }   
        return match.Groups[1].Value + domainName;


*** I would NOT use this without putting some additional controls in your forms (say, 3 trys and quit) ***
 

Ixtabay

Sorceror
Just for fun, here is an update for a more gumpy registration form



Uploaded with ImageShack.us

In EmailRegisterGump.cs

find:
Code:
            AddBackground(47, 372, 409, 140, 9300);
            AddLabel(234, 376, 0, "Register Adress");
 
            AddLabel(121, 404, 0, "Email:");
            AddImage(172, 400, 1143);
            AddTextEntry(180, 402, 255, 20, 0, 2, "" );
 
            AddLabel(58, 443, 0, "Confirm Email:");
            AddImage(172, 437, 1143);
            AddTextEntry(180, 439, 257, 20, 0, 3, "" );
 
            AddButton(135, 474, 4007, 4006, 1, GumpButtonType.Reply, 0);
            AddLabel(172, 476, 0, "Submit");

Replace with:
Code:
            AddImage(251, 176, 1249);
            AddImage(353, 248, 1059);
            AddImage(246, 164, 50990);
            AddImage(467, 164, 50991);
            AddImage(458, 163, 50993);
            AddImage(238, 165, 50992);
            AddImage(376, 403, 5214);
            AddImage(440, 403, 5214);
            AddImage(440, 427, 5214);
            AddImage(376, 427, 5214);
            AddItem(396, 335, 3823);
            AddItem(410, 319, 3823);
            AddItem(423, 333, 3823);
            AddItem(456, 333, 3823);
            AddItem(443, 320, 3823);
            AddItem(396, 335, 3859);
            AddItem(423, 325, 3859);
            AddItem(449, 340, 3859);
            AddItem(466, 327, 3859);
            AddItem(446, 328, 3858);
            AddItem(421, 343, 3858);
            AddItem(446, 330, 3857);
            AddItem(423, 331, 3856);
            AddItem(452, 344, 3856);
            AddItem(403, 332, 3856);
            AddItem(461, 350, 3855);
            AddItem(396, 348, 3855);
            AddItem(492, 276, 2594);
            AddItem(269, 278, 2594);
            AddLabel(399, 298, 67, "Please Register!");
            AddLabel(295, 447, 1014, "Protect your Account!  Take a moment to register!");
            AddLabel(387, 221, 1014, "Welcome to RunUO!");
            AddLabel(295, 400, 67, "Enter Email:");
            AddTextEntry(383, 400, 139, 20, 0, 2, "");
            AddLabel(290, 425, 67, "Verify Email:");
            AddTextEntry(383, 424, 139, 20, 0, 3, "");
            AddButton(536, 411, 247, 248, 1, GumpButtonType.Reply, 0);

Cheers
 
Top