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!

[RUO 2.X] E-Mailing API

Vorspire

Knight
Still sorting through a lot of my older work and came across this E-Mailing API I used to use for my Donation System.
It is basically a collection of data-model classes and a single wrapper class that inherits the .NET MailMessage class.

This system comes with a configuration file which will allow you to define as many SMTP servers as you like in a simple list.

Also included is an example E-Mail message that inherits the wrapper class and shows one way to use this system; It notifies the player by E-Mail whenever they die, the example message assumes that your shard is using an account tag ("email") to store E-Mail addresses.

Config.cs
Rich (BB code):
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Misc;

namespace Server.Emailing
{
	public partial class Config
	{
		/// <summary>
		/// SMTP server list
		/// </summary>
		public static volatile EmailServer[]
			EmailServers = new EmailServer[]
			{
				//new EmailServer("mail.domain.com", 25, "user", "password"),
				//new EmailServer("mail.domain.com", 587, "user", "password"),
				//new EmailServer("mail.domain.com", 691, "user", "password"),
			};
	}
}

EmailExample.cs
Rich (BB code):
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Misc;
using Server.Accounting;

namespace Server.Emailing
{
	public sealed class EventEmailExample
	{
		public static void Initialize()
		{ EventSink.PlayerDeath += new PlayerDeathEventHandler(EventSink_PlayerDeath); }

		private static void EventSink_PlayerDeath(PlayerDeathEventArgs e)
		{
			EmailExample ee = new EmailExample(e.Mobile);

			//You can append the email body with more lines, they will always be added to the bottom of the body.
			//This also means that any lines added will fall below the lines added in the EmailExample class using the Compile override.
			ee.AddLine(DateTime.Now.ToLongDateString()); //Add a simple long date string to the bottom of the email.

			//Always call Send() when your mail is written, or it will go nowhere!
			ee.Send();
		}
	}

	//This is a very basic implimentation of the Email class, there
	//An email sort of works the same way a gump does, each line represents one 'layer'.
	public sealed class EmailExample : Email
	{
		private Mobile _Player;

		public EmailExample(Mobile player)
			: base("[email protected]", ((Account)player.Account).GetTag("email"), "You Are Dead!")
		{ _Player = player; }

		//Override Compile in order to add lines.
		public override void Compile()
		{
			AddLine("Hello, {0}!", _Player.Account.Username);
			AddLineBreak();
			AddLine("Looks like you died.");
			AddLineBreak();
			AddLine("Sorry about that! - The Staff Team.");
			AddLineBreak();
			AddLine("--------------------------------------------------");
		}
	}
}

Plug & Play system.
Have not tested this in a long time (can't test it now).
Will compile without errors, ut I can't guarantee it won't be buggy.

Enjoy!
 

Attachments

  • Emailing.zip
    3.4 KB · Views: 42

Vorspire

Knight
You would have to modify it heavily or even replace the entire EmailClient class before it would be compatible..
However I think I have an old E-Mail registration system I could modify and post up here :)
 

Vorspire

Knight
I'm currently making a re-write of this system, should be available soon, it will extend SSL support from the SMTPClient class.

The re-write will include a simple email registration service too :)
 

jacquesc1

Sorceror
nice love it......
 

Pure Insanity

Sorceror
I'm currently making a re-write of this system, should be available soon, it will extend SSL support from the SMTPClient class.

The re-write will include a simple email registration service too :)

Awesome...we've been planning on adding an email registration system to our shard. I've just been putting it off and working on other things. Now I think I may put it off more and wait for your version. Can't wait to see what you come up with. When you say simple, I'm guessing "automatic" would be considered simple?
 

Vorspire

Knight
When you say simple, I'm guessing "automatic" would be considered simple?

Indeed :)

It will be driven by the RunUO EventSink and do checks and such when the Player logs in.
There will be an option for the way e-mails are handled on a per-shard basis, because on my shard, if an account doesn't have a valid e-mail address linked, it's not playable, the player gets kicked and redirected to a web-page to change their account e-mail address.
-Not everyone will want their shard to rely on that link, being more passive towards registration.
-There will also be a choice of how the registration itself is handled, by which I mean, does the system e-mail a 'pin' code to the address they enter in-game and then prompt for the code before they can continue playing, or does it handle the process via a web-page by e-mailing an activation link, etc...

The system, in the most simple example, can be as easy as:
Code:
//using Server.Emailing;

Email e = new Email( "[email protected]", "[email protected]", "Test Email", "Hello player!\n\nThis is a test e-mail.\n\tPlease do not reply!" );
e.Send();
 

Pure Insanity

Sorceror
Wow, we have two way different versions of simple...lmao.

I can't wait to see what you create, sounds like it will be more than helpful for what I need. =D
 

Vorspire

Knight
Just a little update for those that are waiting on the *new* version of this system...

The API has expanded beyond what was originally planned and it's still not finished.
It's taking a little longer than expected due to my hectic life-style and another high-priority job.

My main aim is to provide the main source of e-mail support for RunUO while keeping compatibility with other systems.
Having factored that into the equation, I've managed to develop this system to be completely drag-and-drop and to be able to work in unison with other e-mailing systems that may be installed.

On the first initial boot, this system will scan your version of RunUO for already existing e-mailing systems, this includes using reflection to detect if the Account class has an Email property, then getting the e-mail from there.
Other ways for scanning include a selection of *known* Account Tags and importing directly from Alex21's "Simple Email Registration" registry.

I have included a dynamic way for developers to be able to easily add their own Import/Export classes for use with e-mail address lists, the standard "Filers" that come with my API handle Plain-Text, Binary and XML formats.
Adding your own "Filer" is extremely easy and will allow you to expand the features of the system.

I would expect to deliver this system to the community before the end of this week :)

ruo-emailing.jpg
 

Pure Insanity

Sorceror
Wow, pretty amazing so far Vorpsire. I know there have been similar systems before in the past, but none of them were built quite as well. Seems like at least 80% of the posts for the old systems, are people complaining that it didn't work. I can't wait to test your new system when it's done. I'll do my best to help you stress test it and see if I can break it. =P
 

Vorspire

Knight
Sounds like a plan, that would be helpful since I won't be able to do any real testing since my shard isn't public :p

I'm writing this in 2.1, but it should also work with 2.0 and by request, 1.0 :)

[EDIT]

If at all possible, I need 5 people who would like to beta test this system before I release it.
If you're interested, just PM me :)
 

Vorspire

Knight
Complexity update, console output preview:
Code:
[Emailing/Invoker]: Thread `Server.Emailing` Starting...
[Emailing/Events]: Invoking...
[Emailing/Events]: Registering handlers...
[Emailing/Events]: Handlers registered.
[Emailing/Events]: Operational.
[Emailing/Handler]: Invoking...
[Emailing/Handler]: Configuring E-Mail Server `SMTP1`...
[Emailing/Handler]: 50.0% (1 of 2)
[Emailing/Handler]: Configuring E-Mail Server `SMTP1 Secure`...
[Emailing/Handler]: 100.0% (2 of 2)
[Emailing/Handler]: 2 E-Mail Server records were configured.
[Emailing/Handler]: No E-Mail Server records were invalid.
[Emailing/Handler]: Operational.
[Emailing/Tracker]: Invoking...
[Emailing/Tracker]: Importing from `C:\RunUO_2_1\EmailList.txt`...
[Emailing/Tracker]: 5 E-Mail Address records were imported.
[Emailing/Tracker]: Synchronizing data sources...
[Emailing/Tracker]: No E-Mail Address records were synchronized.
[Emailing/Tracker]: No E-Mail Address records were invalid.
[Emailing/Tracker]: Exporting to `C:\RunUO_2_1\EmailList.txt`...
[Emailing/Tracker]: 5 E-Mail Address records were exported.
[Emailing/Tracker]: Operational.
[Emailing/Invoker]: Thread `Server.Emailing` has been started.
Code:
World: Saving...
[Emailing/Tracker]: World Save detected...
[Emailing/Tracker]: Exporting to `C:\RunUO_2_1\EmailList.txt`...
[Emailing/Tracker]: 5 E-Mail Address records were exported.

EmailList.txt format:
Code:
"account" <[email protected]>

EmailList.txt content preview:
Code:

Other EmailList database formats include XML and Binary. There is also a database for importing and exporting the files generated by "Simple Email Registration".

[EDIT]

I'm just finalizing the User Interface, it's taken much longer than expected because of the underlying design (which will hopefully become a Gump framework in a later project release).
Error_Dialog_Test.jpg
 

Pure Insanity

Sorceror
Pst...dug up this post so you could remember that you have this system laying around that needs to be finished...I'd more than willing to give you a hand. =P
 

Vorspire

Knight
Nope, this one got finished, I just haven't updated this post yet and I don't feel like releasing it right now because it has not been fully tested. You may ave noticed I have *a lot* of unfinished work, hard to keep track of it all, but I have a list of priorities and I'm constantly working with Pandora, which is top priority right now :/

You really don't have to remind me about my own work, it's all on the list, priorities change.
This community seems to be going through another phase of "we're entitled" and as such, is another reason for holding back my releases.
The morale of the story is "good things come to those who wait".
 

duponthigh

Sorceror
Well, Im not sure about everyone else.My self I do get excited to see some of the work you have done.Its true you have done wonderfull things.I always apperciate the scripts you ahave submited, as do most of the communityJust to let ya know.If it bothers you that much for people to ask for updates about your scripts-or just simply say they cant wait.Why Post your updates to get people worked up?Why not wait till your done and maybe you would not feel that way.As far as you not releasing your finished work not that big of a surprise.You have done that on other projects, script submissions.Personaly danglen candy over a hungry baby, never a good idea.Of course the community is going to want it.Just my thought on it.....
 

Pure Insanity

Sorceror
Woah dude, chill out. I know what it's like to have a ton of things on your plate. I don't feel I'm entitled to anything. Just you got me hyped about this a long time ago, and I've been wanting to test it for you for a while.

Only reason I bumped the topic, was because I recently did an email registration system for my shard. Works fine and all...does exactly what I need. Just really wanted to still take a look at what you came up with. Mainly so I could adapt my system so your's can read player emails from my system, as I have no clue how your system works atm.

Take your time, and even if you decide to never release it...it's not the end of the world.
 
Top