public void Send(MailMessage message) { bool b = (message.From.IsNull() || message.From.Address.IsNull() || !RegexUtility.IsValidEmail(message.From.Address)); bool b1 = (message.To.IsNull() || message.To.Count == 0 || message.To[0].Address.IsNull() || !RegexUtility.IsValidEmail(message.To[0].Address)); if (b || b1) { return; } //It so happen that the DEV certificates are invalid. Let the server callback when a certificate comes in ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; var client = new SmtpClient { UseDefaultCredentials = false, DeliveryMethod = SmtpDeliveryMethod.Network, Credentials = new NetworkCredential("no-reply", "*****@*****.**"), Host = "mail.xyz.ir", EnableSsl = true, Port = 25, }; client.SendAsync(message, null); client.SendCompleted += ClientSendCompleted; }
private void DoSignin(string account, string pwd) { if (String.IsNullOrEmpty(account)) { throw new Exception("Input the account name or email"); } if (String.IsNullOrEmpty(pwd)) { throw new Exception("Input the password."); } CDBUser usr = null; if (RegexUtility.IsValidEmail(account)) { usr = dbAdapter.FindUserByEmail(account); } else { usr = dbAdapter.FindUserByAlias(account); } if (usr == null) { throw new Exception("Not registered account."); } if (pwd != usr.pwd) { throw new Exception("Password invalid"); } CSessionMgr.Login(usr.id, usr.alias); }
public void SendMail(Applicant applicant, string body) { if (string.IsNullOrEmpty(applicant.EMail) || !RegexUtility.IsValidEmail(applicant.EMail)) { return; } var mailMessage = new MailMessage(); mailMessage.To.Add(applicant.EMail); mailMessage.From = new MailAddress("*****@*****.**"); mailMessage.Body = body; mailMessage.Subject = "Confirmation Mail"; mailMessage.IsBodyHtml = true; if (applicant.CV.IsNotNull() && applicant.CV.Contents.IsNotNull()) { mailMessage.Attachments.Add( new Attachment(new MemoryStream(applicant.CV.Contents), applicant.CV.ContentType) { Name = applicant.CV.FileName }); } this.emailService.Send(mailMessage); }