Tibzy

Member
Hey guys i am just a bit confused as to how to configure this script properly. If you could guide me in to what exactly to fill in up the top that would be much help.
using System;
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.Misc
{
public class RegisterEmailClient
{
public static bool Enabled = true; // Is this system enabled?

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

public static string EmailServer = "gmail.com"; // Your mail server here
public static string User = "[email protected]"; // Your username here
public static string Pass = "mypass"; // 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;

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);
}
}

public static void SendMail(EmailEventArgs e)
{
bool single = e.Single;

if (single)
{
ThreadPool.QueueUserWorkItem(new WaitCallback(SendSingal), e);
}
else
{
ThreadPool.QueueUserWorkItem(new WaitCallback(SendMultiple), e);
}

return;
}

private static void SendMultiple(object e)
{
EmailEventArgs eea = (EmailEventArgs)e;

List<MailAddress> emails = (List<MailAddress>)eea.Emails;
string sub = (string)eea.Subject;
string msg = (string)eea.Message;

for (int i = 0; i < emails.Count; ++i)
{
MailAddress ma = (MailAddress)emails;

mm.To.Add(ma);
}

mm.Subject += " - " + sub;
mm.Body = msg;

try
{
client.Send(mm);
}
catch { }
mm.To.Clear();
mm.Body = "";
mm.Subject = ServerName;

return;
}

private static void SendSingal(object e)
{
EmailEventArgs eea = (EmailEventArgs)e;

string to = (string)eea.To;
string sub = (string)eea.Subject;
string msg = (string)eea.Message;

mm.To.Add(to);
mm.Subject += " " + sub;
mm.Body = msg;

try
{
client.Send(mm);
}
catch { }
mm.To.Clear();
mm.Body = "";
mm.Subject = ServerName;

return;
}
}

public class EmailEventArgs
{
public bool Single;
public List<MailAddress> Emails;
public string To;
public string Subject;
public string Message;

public EmailEventArgs(bool single, List<MailAddress> list, string to, string sub, string msg)
{
Single = single;
Emails = list;
To = to;
Subject = sub;
Message = msg;
}
}
}

 
Dunno where u got this script from, but its slightly different than mine. I don't see a TLS port option in your email script. I've got mine to where it will send the auth code to players, but when the server shuts down I'm also having an issue with it saving the profiles. If anyone could also help me, would be much appreciated
Post automatically merged:

Should look something like this
C#:
               Host = EmailServer,
               Port = 587,
               EnableSsl = true,
               DeliveryMethod = SmtpDeliveryMethod.Network,
               UseDefaultCredentials = false,
               Credentials = new NetworkCredential(User, Pass)

The Email Server = smpt.gmail.com

and heres a tutorial video for how to go about enabling pop3 and IMAP in gmail settings.
Post automatically merged:

To view this content we will need your consent to set third party cookies.
For more detailed information, see our cookies page.
Post automatically merged:

Email server = smtp.gmail.com * had a typo
Post automatically merged:

I also just fixed mine!
I changed
"UseDefaultCredentials = True
 
Last edited:

Active Shards

Donations

Total amount
$80.00
Goal
$1,000.00
Back