예제 #1
0
        public bool TrySendEmail(ContactModel model)
        {
            const string fromPassword = "";
            string body = string.Format(_messageFormat, model.Name, model.Email, model.Message);

            var smtp = new SmtpClient("smtp.gmail.com", 587)
                       {
                           Credentials = new NetworkCredential(_myEmail, fromPassword),
                           EnableSsl = true
                       };
            try
            {
                smtp.Send(_myEmail, _myEmail, model.Subject, body);
                return true;
            }
            catch (SmtpException e)
            {
                return false;
            }
        }
예제 #2
0
 public ActionResult Send(ContactModel model)
 {
     var success = _emailProvider.TrySendEmail(model);
     return View("Index");
 }