예제 #1
0
        public static void Email_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            // check arguments
            if (e.Length != 3)
            {
                Usage(from);
                return;
            }

            try
            {
                string To      = e.GetString(0);
                string Subject = e.GetString(1);
                string Body    = e.GetString(2);

                if (SmtpDirect.CheckEmailAddy(To, true) == false)
                {
                    from.SendMessage("Error: The 'to' address is ill formed.");
                    return;
                }

                // okay, now hand the list of users off to our mailer daemon
                new Emailer().SendEmail(To, Subject, Body, false);
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                System.Console.WriteLine("Exception Caught in generic emailer: " + ex.Message);
                System.Console.WriteLine(ex.StackTrace);
            }

            return;
        }
예제 #2
0
            public static object StandardEmail(object parms)
            {
                try
                {
                    ParamPack px = parms as ParamPack;

                    // hmm.. badness
                    if (px == null || px.m_toAddress == null)
                    {
                        string message = String.Format("Error: in Accounting.Emailer. paramater pack.");
                        throw new ApplicationException(message);
                    }

                    // Adam: bacause we may send this to both the recipient and the email archive server
                    //  we allow distribution lists
                    if (SmtpDirect.CheckEmailAddy(px.m_toAddress, true) == false)
                    {
                        string message = String.Format("Email: Bad address detected '{0}'.", px.m_toAddress);
                        throw new ApplicationException(message);
                    }

                    SmtpDirect mail = new SmtpDirect();
                    mail.SendEmail(px.m_toAddress, px.m_subject, px.m_body, px.m_ccRegistration);
                    return(true);
                }
                catch (Exception e)
                {
                    LogHelper.LogException(e);
                    Console.WriteLine("Exception: " + e.Message);
                    Console.WriteLine(e.StackTrace);
                }

                return(false);
            }
예제 #3
0
            public static object DistributionList(object parms)
            {
                try
                {
                    ParamPack px = parms as ParamPack;

                    // hmm.. badness
                    if (px == null || px.m_distributionList == null)
                    {
                        try { throw new ApplicationException("Error: in Accounting.Emailer. paramater pack."); }
                        catch (Exception ex) { Server.EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
                        return(false);
                    }

                    // for now, just print them
                    for (int ix = 0; ix < px.m_distributionList.Count; ix++)
                    {
                        // pause for 1 second between sends
                        //	if we are sending to N thousand players, we don't want to
                        //	eat all our bandwidth
                        System.Threading.Thread.Sleep(1000);

                        string addy = px.m_distributionList[ix] as string;
                        if (addy == null)
                        {
                            continue;                                                                   // may not be null
                        }
                        // Adam: bacause recipient is specified, we do not allow distribution lists
                        if (SmtpDirect.CheckEmailAddy(addy, false) == false)
                        {
                            Console.WriteLine("Email: Bad address detected '{0}'.", addy);
                            continue;
                        }

                        Console.WriteLine("Email: Sending  {0} of {1}.", ix + 1, px.m_distributionList.Count);

                        // send it baby!
                        new SmtpDirect().SendEmail(addy, px.m_subject, px.m_body, false);
                    }

                    Console.WriteLine("Done.");
                    return(px.m_distributionList.Count);
                }
                catch (Exception e)
                {
                    LogHelper.LogException(e);
                    Console.WriteLine("Exception: " + e.Message);
                    Console.WriteLine(e.StackTrace);
                }

                return(0);
            }
예제 #4
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            int val = info.ButtonID;

            if (val <= 0)
            {
                return;
            }

            Mobile from = m_From;

            switch (val)
            {
            case 1:
                string accountname = info.GetTextEntry(0).Text;
                m_From.SendMessage("You entered [{0}]", accountname);

                foreach (Accounting.Account a in Accounting.Accounts.Table.Values)
                {
                    if (a != null)
                    {
                        if (a.Username.ToLower() == accountname.ToLower())
                        {
                            if (a.AccountActivated)
                            {
                                if ((DateTime.Now - a.ResetPasswordRequestedTime) < TimeSpan.FromDays(1.0))
                                {
                                    m_From.SendMessage("Reset password already requested.");
                                }
                                else
                                {
                                    string newResetPassword = Server.Gumps.ProfileGump.CreateActivationKey(8);
                                    if (SmtpDirect.CheckEmailAddy(a.EmailAddress, false) == true)
                                    {
                                        string subject = "Angel Island Account password reset request";
                                        string body    = "\nSomeone has requested a password reset for your account.\n";
                                        body += "A new password has been generated for your account.\n";
                                        body += "It is: " + newResetPassword;
                                        body += "\n\nIf you did not request this reset password, log onto Angel Island with your normal ";
                                        body += "password and the reset request will be cancelled.  Also, please report this ";
                                        body += "to the staff of Angel Island.";
                                        body += "\n\nYou can change your password using the [profile command.\n\n";
                                        body += "Regards,\n  The Angel Island Team\n\n";

                                        Emailer mail = new Emailer();
                                        if (mail.SendEmail(a.EmailAddress, subject, body, false))
                                        {
                                            string regSubject = "Password reset request";
                                            string regBody    = "Password reset reqest made.\n";
                                            regBody += "Info of from: \n";
                                            regBody += "\n";
                                            Accounting.Account from_account = m_From.Account as Accounting.Account;
                                            regBody += "Account: " + (from_account == null ? "<unknown>" : from_account.Username) + "\n";
                                            regBody += "Character: " + from.Name + "\n";
                                            regBody += "IP: " + sender.Address.ToString() + "\n";
                                            regBody += "\n";
                                            regBody += "Account requested for: " + a.Username + "\n";
                                            regBody += "Email: " + a.EmailAddress + "\n";
                                            regBody += "Reset password: "******"\n";
                                            regBody += "\n";
                                            mail.SendEmail("*****@*****.**", regSubject, regBody, false);

                                            a.ResetPassword = newResetPassword;
                                            m_From.SendMessage("Password reset request generated.");
                                            m_From.SendMessage("Email sent to account's email address.");
                                        }
                                        else
                                        {
                                            m_From.SendMessage("Error sending email to account's email.");
                                        }
                                    }
                                    else
                                    {
                                        m_From.SendMessage("Account email invalid, unable to reset password.");
                                    }
                                }
                            }
                            else
                            {
                                m_From.SendMessage("Account not activated, unable to reset password.");
                            }
                            break;
                        }
                    }
                }

                break;

            default:
                break;
            }
        }