public ServerResult <object> ChangeSmtpMailInfo(SmtpMailInfo mailInfo)
        {
            var dic = new Dictionary <string, string>();

            dic.Add("email", mailInfo.Email);
            dic.Add("password", mailInfo.Password);
            dic.Add("smtp_server", mailInfo.SmtpServer);
            dic.Add("smtp_server_port", mailInfo.SmtpPServerPort.ToString());
            dic.Add("ssl", mailInfo.SSL.ToString());
            var json   = HttpHelper.Get(this.urlChangeMailInfo, dic, key);
            var result = JsonConvert.DeserializeObject <ServerResult <object> >(json);

            return(CheckResult(result));
        }
        private bool handleMailTab(bool isClose)
        {
            var mail       = Mail.Text.Trim();
            var password   = Password.Password.Trim();
            var smtpServer = SmtpServer.Text.Trim();
            var port       = SmtpServerPort.Text.Trim();
            var ssl        = SSL.IsChecked.Value ? 1 : 0;
            var validate   = new Validate();

            validate.AddCmd(new ValidateCmd(mail, "邮箱地址未输入"));
            validate.AddCmd(new ValidateCmd("邮箱格式不正确", delegate() {
                return(Validate.IsMail(mail));
            }));
            validate.AddCmd(new ValidateCmd(password, "密码未输入"));
            validate.AddCmd(new ValidateCmd(port, "端口未输入"));
            validate.AddCmd(new ValidateCmd("端口格式不正确", delegate() {
                return(Validate.IsInteger(port));
            }));
            if (!validate.Execute())
            {
                return(false);
            }
            var mailInfo = new SmtpMailInfo();

            mailInfo.Email           = mail;
            mailInfo.Password        = password;
            mailInfo.SmtpServer      = smtpServer;
            mailInfo.SmtpPServerPort = int.Parse(port);
            mailInfo.SSL             = ssl;

            var result = dataSource.ChangeSmtpMailInfo(mailInfo);

            if (result.Code == ServerResult <object> .CODE_ERROR)
            {
                MessageBox.Show(result.Message);
                return(false);
            }
            if (isClose)
            {
                Close();
            }
            return(true);
        }
Beispiel #3
0
    ArrayList GetSenderList()
    {
        ArrayList senders = new ArrayList();

        SmtpMailInfo info = null;

        while ((info = m_stServerInfo.GetCurrentSmtp()) != null)
        {
            Hashtable item = new Hashtable();
            item["id"]   = info.userID;
            item["pwd"]  = info.userPwd;
            item["smtp"] = info.smtpHost;
            item["ssl"]  = info.sslEnable;
            senders.Add(item);

            m_stServerInfo.SetNextSmtp();
        }
        m_stServerInfo.ResetSmtpIndex();

        return(senders);
    }
Beispiel #4
0
        /// <summary>
        /// Lista la configuracion para enviar correo.
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public SmtpMailInfo ListxId(int Id)
        {
            db.SetParameterValue(commandMail, "i_operation", 'S');
            db.SetParameterValue(commandMail, "i_option", 'A');
            db.SetParameterValue(commandMail, "i_mai_id", Id);

            IDataReader dr = null;

            SmtpMailInfo m = null;

            try
            {
                dr = db.ExecuteReader(commandMail);

                if (dr.Read())
                {
                    m = Factory.GetMail(dr);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(string.Format("NIVI Error: {0} , NameSpace: {1}, Clase: {2}, Metodo: {3} ", ex.Message, MethodBase.GetCurrentMethod().DeclaringType.Namespace, MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name));

                bool rethrow = ExceptionPolicy.HandleException(ex, "DataAccess Policy");

                if (rethrow)
                {
                    throw;
                }
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }

            return(m);
        }
Beispiel #5
0
    IEnumerator SendDebugToMail(LogStruct lastexception, string gmailID = "", string gmailPwd = "", string unreportedMessageBody = "")
    {
        if (m_bCrashCatched != true)
        {
            m_bCrashCatched = true;
            AnalyticsImplement(lastexception);

            UnityEngine.Debug.Log("SendDebugToMail ");
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("CrashReporter");

            if (m_strMailingList.Length > 0 && m_strMailingList.IndexOf(";") != -1)
            {
                string[] sliceList = m_strMailingList.Split(';');
                for (int i = 0; i < sliceList.Length; i++)
                {
                    mail.To.Add(sliceList [i]);
                    //				UnityEngine.Debug.Log(sliceList[i]);
                }
            }
            else if (m_strMailingList.Length > 0)
            {
                mail.To.Add(m_strMailingList);
            }
            else
            {
                yield return(null);
            }

            mail.Subject = "[" + m_strProjectName + " CrashReport - " + lastexception.type.ToString() + " #" + m_strBuild_version.ToString() + " ] " + m_stUserInfo.teamname + " #" + DateTime.Now;

            mail.Body = unreportedMessageBody.Length > 0 ? unreportedMessageBody : MakeMassageHeader(BufferToText());


            ScreenShotRoutine((attachmentPath) => {
                if (unreportedMessageBody.Length <= 0)
                {
                    WriteFileLog(mail.Body, lastexception.stacktrace, lastexception.type == LogType.Exception);
                }
                try {
                    if (File.Exists(attachmentPath))
                    {
                        Attachment inline = new Attachment(attachmentPath);
                        string contentID  = Path.GetFileName(attachmentPath).Replace(".", "") + "@zofm";
                        inline.ContentDisposition.Inline          = true;
                        inline.ContentDisposition.DispositionType = DispositionTypeNames.Inline;
                        inline.ContentId             = contentID;
                        inline.ContentType.MediaType = "image/png";
                        inline.ContentType.Name      = Path.GetFileName(attachmentPath);

                        mail.Attachments.Add(inline);
                    }

                    SmtpClient smtpServer            = new SmtpClient();
                    smtpServer.Host                  = m_stServerInfo.GetCurrentSmtp().smtpHost;
                    smtpServer.Port                  = 587;
                    smtpServer.EnableSsl             = m_stServerInfo.GetCurrentSmtp().sslEnable;
                    smtpServer.DeliveryMethod        = System.Net.Mail.SmtpDeliveryMethod.Network;
                    smtpServer.UseDefaultCredentials = false;
                    smtpServer.Credentials           = new System.Net.NetworkCredential(gmailID,
                                                                                        gmailPwd) as ICredentialsByHost;

                    ServicePointManager.ServerCertificateValidationCallback =
                        delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
                        return(true);
                    };

                    smtpServer.Send(mail);
                    UnityEngine.Debug.Log("send finish");

                    FinalWorking(unreportedMessageBody.Length > 0);
                } catch (Exception ex) {
                    Debug.Log("Can't send crashreporter mail, smtp sending error : " + ex.Message);

                    SmtpMailInfo info = m_stServerInfo.GetCurrentSmtp();
                    if (info != null)
                    {
                        m_stServerInfo.SetNextSmtp();
                        m_bCrashCatched = false;
                        Routine(SendDebugToMail(lastexception, info.userID, info.userPwd));
                    }
                }
            });
        }

        yield return(null);
    }
Beispiel #6
0
 public void AddSmtp(SmtpMailInfo smtp)
 {
     ResetSmtpIndex();
     smtpList.Add(smtp);
 }