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
EmailExample.cs
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!
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!