Beispiel #1
0
        private void btnTestMail_Click(object sender, EventArgs e)
        {
            CryptManager.Init(Settings);
            string from        = Settings.MailFrom;
            string to          = Settings.MailTo;
            int    port        = Settings.MailPort;
            string smtpAddress = Settings.MailSmtp;
            string userName    = Settings.MailUserNamer;
            string passwort    = CryptManager.Decrypt(Settings.MailCryptPasswort);

            MailMessage message = new MailMessage();

            message.To.Add(to);
            message.Subject = String.Concat("Testmail - Error on SFBoty on ", Settings.Server, " with Player ", Settings.Username);
            message.From    = new MailAddress(from);
            message.Body    = "Dies ist eine Testmail";

            SmtpClient smtp = new SmtpClient(smtpAddress, port);

            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.EnableSsl      = true;
            smtp.Credentials    = new NetworkCredential(userName, passwort);
            smtp.Timeout        = 30000;

            try {
                smtp.Send(message);
                MessageBox.Show("Mail wurde gesendet.");
            } catch {
                MessageBox.Show("Mail wurde nicht gesendet.");
            }

            message.Dispose();
            smtp.Dispose();
        }
Beispiel #2
0
 private void txtPasswort_TextChanged(object sender, EventArgs e)
 {
     Settings.PasswordHash = txtPasswort.Text;
     if (!String.IsNullOrEmpty(Settings.MailCryptPasswort))
     {
         CryptManager.Init(string.Concat(pw, server, acc));
         string orgPW = CryptManager.Decrypt(Settings.MailCryptPasswort);
         CryptManager.Init(Settings);
         Settings.MailCryptPasswort = CryptManager.Encrypt(orgPW);
     }
     pw = Settings.PasswordHash;
 }
Beispiel #3
0
        public void SetSettings(AccountSettings settings)
        {
            Settings = settings;

            CryptManager.Init(Settings);

            txtFrom.Text = settings.MailFrom;
            txtTo.Text   = settings.MailTo;
            txtSmtp.Text = settings.MailSmtp;
            txtUser.Text = settings.MailUserNamer;
            if (!string.IsNullOrEmpty(settings.MailCryptPasswort))
            {
                txtPasswort.Text = CryptManager.Decrypt(settings.MailCryptPasswort);
            }
            numPort.Value            = settings.MailPort;
            ckbSendErrorMail.Checked = settings.SendErrorMail;
        }
Beispiel #4
0
        private void SendErrorMail(string body)
        {
            CryptManager.Init(Account.Settings);
            string from        = Account.Settings.MailFrom;
            string to          = Account.Settings.MailTo;
            int    port        = Account.Settings.MailPort;
            string smtpAddress = Account.Settings.MailSmtp;
            string userName    = Account.Settings.MailUserNamer;
            string passwort    = CryptManager.Decrypt(Account.Settings.MailCryptPasswort);

            MailMessage message = new MailMessage();

            message.To.Add(to);
            message.Subject = String.Concat("Error on SFBoty on ", Account.Settings.Server, " with Player ", Account.Settings.Username);
            message.From    = new MailAddress(from);
            message.Body    = body;

            SmtpClient smtp = new SmtpClient(smtpAddress, port);

            smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
            smtp.EnableSsl      = true;
            ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); };
            smtp.Credentials = new NetworkCredential(userName, passwort);
            smtp.Timeout     = 30000;

            try {
                smtp.Send(message);
            } catch (Exception ex) {
                if (MessageOutput != null)
                {
                    MessageOutput(this, new MessageEventsArgs("Mail konnte nicht gesendet werden."));
                }

                if (Error != null)
                {
                    Error(this, new MessageEventsArgs("Mail konnte nicht gesendet werden." + Environment.NewLine + ex.ToString()));
                }
            }

            message.Dispose();
            smtp.Dispose();
        }
Beispiel #5
0
 public static string Decrypt(this string textToDecrypt)
 {
     return(CryptManager.Decrypt(textToDecrypt));
 }