jeudi 28 avril 2016

Is this possible to send email in mvc 3 without password

i have a form check from that will send mail with data using following code

Controller

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

        {
            EmailManager.Enquiry(Position, txtname, txtemail, txtmsg);
            return Redirect("Index");
        }

EmailManager:

public static void Enquiry(string Position, string txtname, string txtemail, string txtmsg)
        {
            using (var client = new SmtpClient())
            {
                using (var message = new MailMessage(txtemail, EmailTo))
                {
                    message.Subject = "Job Entry";
                    message.Body = "<html><head><meta content=\"text/html; charset=utf-8\" /></head><body><p>Position: " + Position +
                        ", </p> <p>Email<span>:</span>" + txtemail +
                         ", </p> <p>Name:" + txtname +
                    ", </p> <p>Message:" + txtmsg +
                    ",</p>"
                        + "</a></p><div></div><div></div></body></html>";

                    message.IsBodyHtml = true;
                    client.EnableSsl = true;
                    client.Send(message);
                };
            };
        }

In web config

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="smtp.gmail.com" port="587" userName="ex@gmail.com" password="pwd" />
      </smtp>
    </mailSettings>
  </system.net>

My question ,

1.is this possible to send a mail without network host
2. you can see a textbox(email) in enter image description here, is this possible to send a mail from textbox(email id ) to xyz@gmail.com ??

thanks in advance

Aucun commentaire:

Enregistrer un commentaire