jeudi 28 avril 2016

Mail not sending in mvc 3

i have posted my source that having porblem named

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 68.178.232.62:25

i have implemented by ref of

http://ift.tt/1pNovkD

please help me to solve this issue

thanks in advance :)

View Page

 @using (Html.BeginForm("Emailto", "Home", FormMethod.Post))
    {
@Html.TextBoxFor(a => a.Position, new { @readonly = "readonly", @id = "Position", @name = "Position" })
  <input type="text" value="" id="txtname" name="txtname" required />
  <input type="email" value="" id="txtemail" name="fromEmail"  required />
<input type="submit" id="btnApply" name="btnApply" value="Apply" />

Controller

[HttpPost, ValidateInput(false)]
        public ActionResult Emailto(string Position, string txtname, string fromEmail)

        {
            EmailManager.SendMessage(Position, txtname, fromEmail);
            return Redirect("Index");
        }

EmailManager

[System.Web.Services.WebMethod]
        public static void SendMessage(string Position, string txtname, string fromEmail)
        {
            const string SERVER = "relay-hosting.secureserver.net";
            const string TOEMAIL = "riayz@acute.company";
            MailAddress from = new MailAddress(fromEmail);
            MailAddress to = new MailAddress(TOEMAIL);
            MailMessage message = new MailMessage(from, to);

            message.Subject = "Position " + Position;
            message.Body = "Message from: " + Position + " at " +
                           fromEmail + "\n\n" + txtname;
            message.IsBodyHtml = false;
            SmtpClient client = new SmtpClient(SERVER);
            client.Send(message);
        }
    }

Aucun commentaire:

Enregistrer un commentaire