예제 #1
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);
            }
예제 #2
0
        private static void SendEmail(string filePath)
        {
            Console.Write("Crash: Sending email...");

            try
            {
                MailMessage message = new MailMessage();
                message.Subject = "Automated RunUO Crash Report";
                if (Server.Misc.TestCenter.Enabled)
                {
                    message.Subject += " (Test Center)";
                }
                message.From = new MailAddress(SmtpDirect.FromEmailAddress);
                message.To.Add(SmtpDirect.ClassicList(Emails));
                message.Body = "Automated RunUO Crash Report. See attachment for details.";
                message.Attachments.Add(SmtpDirect.MailAttachment(filePath));

                bool result = new SmtpDirect().SendEmail(message);
                Console.WriteLine("done: {0}", result.ToString());
            }
            catch
            {
                Console.WriteLine("failed");
            }
        }
예제 #3
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;
        }
예제 #4
0
        private static void SendEmail(string body, bool testcenter)
        {
            Console.Write("Sending email...");

            try
            {
                MailMessage message = new MailMessage();
                if (testcenter)
                {
                    message.Subject = "Automated RunUO Rebuild/Merge Report Test Center";
                }
                else
                {
                    message.Subject = "Automated RunUO Rebuild/Merge Report Production";
                }

                message.From = new MailAddress(SmtpDirect.FromEmailAddress);
                message.To.Add(SmtpDirect.ClassicList(Emails));
                message.Body = "Automated RunUO Rebuild/Merge Report" + body;

                bool result = new SmtpDirect().SendEmail(message);
                Console.WriteLine("done: {0}", result.ToString());
            }
            catch
            {
                Console.WriteLine("failed");
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            string dest = "*****@*****.**";

            string[] elems = dest.Split("@".ToCharArray());
            string[] arr   = Mx.GetMXRecords(elems[1]);

            string s = "";

            foreach (string x in arr)
            {
                s += x + Environment.NewLine;
            }
            Console.WriteLine("MX records:" + Environment.NewLine + s);

            MailMessage msg = new MailMessage();

            msg.To                = dest;
            msg.From              = "*****@*****.**";
            msg.Subject           = "Hello, world";
            msg.Body              = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
            SmtpDirect.SmtpServer = arr[0];

            SmtpDirect.Send(msg);
            Console.WriteLine(SmtpDirect.output.ToString());

            Console.ReadKey();
        }
예제 #6
0
        public static void prueba1()
        {
            System.Web.Mail.MailMessage mail = new System.Web.Mail.MailMessage();
            mail.From    = "*****@*****.**";
            mail.To      = "*****@*****.**";
            mail.Subject = "Prueba";
            mail.Body    = "Hola luuuuuu";

            SmtpDirect.Send(mail);
        }
예제 #7
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);
            }
예제 #8
0
        public static void SendEMail(string from, string to, string smtpServer, string body, MailFormat format, string subject, bool highPriority, MailAttachment[] attachments, bool throghSmtpDirect)
        {
            try
            {
                MailMessage message = new MailMessage();
                message.From    = from;
                message.To      = to;
                message.Subject = subject;
                if (highPriority)
                {
                    message.Priority = MailPriority.High;
                }
                message.BodyEncoding = Encoding.ASCII;
                message.BodyFormat   = format;
                message.Body         = body;

                foreach (MailAttachment attachment in attachments)
                {
                    message.Attachments.Add(attachment);
                }

                if (throghSmtpDirect)
                {
                    SmtpDirect.SmtpServer = smtpServer;
                    SmtpDirect.Send(message);
                }
                else
                {
                    SmtpMail.SmtpServer = smtpServer;
                    SmtpMail.Send(message);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
예제 #9
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;
            }
        }