从asp.net页面发送电子邮件的问题 [英] Problem with sending email from asp.net page
问题描述
您好b $ b
我们可以在实时网站上使用gmail smtp将联系人表格中的邮件(反馈)发送给网站所有者,是否可以?
$ b
邮件从反馈表发送到当地主机的欲望电子邮件ID。
但是当同一项目上传到实时网络服务器时出现问题。
点击反馈表单中的提交按钮没有任何反应。
什么问题出在哪里我无法理解?
因为这个应用程序在本地主机上运行正常。
请指导我一下这个问题。
点击提交按钮时,这一行会附加网址。
__EVENTTARGET = &安培; __ EVENTARGUMENT =安培; __ VIEWSTATE =%2FwEPDwUKMTk2Njc5ODE2N2RkEGPdgAflCjv7N%2Fj8z04OHUSWDag%3D&安培; __ EVENTVALIDATION =%2FwEWBgLzi4feDwK0w7i7DQK9w4QnAqHo7y4C9oCMmQwCro6e7AMCSNU4FMIyaDwIGsIYTXrxUJrXnQ%3D%3D&安培; ctl00%24ContentPlaceHolder1% 24txtName = balwant& ctl00%24ContentPlaceHolder1%24txtMail = balwant.mnd%40gmail.com& ctl00%24ContentPlaceHolder1%24txtFeed = testing& ctl00%24ContentPlaceHolder1%24btsubmit = Submit
<发送电子邮件的代码如下:
Hi
can we use gmail smtp in live website to send mail(feedback) from contactus form to the owner of the website, is it possible?
mail is send to the desire email id from local host from feedback form.
but problem occur when the same project uploaded to the live web server.
on clicking the submit button in the feedback form nothing happen.
what and where is the problem i can't get that?
because this application behave normal at local-host.
please guide me regarding this problem.
this line is appended with the url while clicking on submit button.
__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=%2FwEPDwUKMTk2Njc5ODE2N2RkEGPdgAflCjv7N%2Fj8z04OHUSWDag%3D&__EVENTVALIDATION=%2FwEWBgLzi4feDwK0w7i7DQK9w4QnAqHo7y4C9oCMmQwCro6e7AMCSNU4FMIyaDwIGsIYTXrxUJrXnQ%3D%3D&ctl00%24ContentPlaceHolder1%24txtName=balwant&ctl00%24ContentPlaceHolder1%24txtMail=balwant.mnd%40gmail.com&ctl00%24ContentPlaceHolder1%24txtFeed=testing&ctl00%24ContentPlaceHolder1%24btsubmit=Submit
my code for sending email is as follow:
protected void btSubmit_Click(object sender, EventArgs e)
{
try
{
SmtpClient smtpClient = new SmtpClient();
MailMessage objMail = new MailMessage();
//From Address will be assigned from the e-mail specified in the From TextField You can also give the code given below.
MailAddress objMail_fromaddress = new MailAddress(txtMail.Text);
MailAddress objMail_toaddress = new MailAddress("mymail@gmail.com");
objMail.IsBodyHtml = true;
//Assigning From address to the MailMessage class
objMail.From = objMail_fromaddress;
//Assigning To address to the MailMessage class as a collection
objMail.To.Add(objMail_toaddress);
objMail.Subject = "Feedback from" + txtName.Text + " to us from Contact us Form";
objMail.Body = "Message from" + txtName.Text + "as comments:-" + txtComments.Text + "<br><br><br>" + "Address:" + txtAddress.Text + "<br>Mobile no:" + txtTel.Text;
objMail.Priority = MailPriority.High;
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587
smtpClient.Credentials = new System.Net.NetworkCredential("mymail@gmail.com", "1239807643");
smtpClient.EnableSsl = true;
smtpClient.Send(objMail);
Label1.Visible = true;
Label1.Text = "your feedback is submitted successfully.";
}
catch (Exception ex)
{
Label1.Visible = true;
Label1.Text = "something went wrong!, Please Try Again." + ex.Message;
}
推荐答案
可能是由于种种原因。您需要逐个查看它们。
端口是否打开?防火墙权限到位了吗?
进一步确保在Web中配置了SMTP配置。配置:
It can be because of various reasons. You need to look at them one by one.
Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config:
<system.net>
<mailSettings>
<smtp from="abc@somedomain.com">
<network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
</smtp>
</mailSettings>
</system.net>
如果需要,请查看此Microsoft视频教程:
使用ASP.NET从网站发送电子邮件 [ ^ ]
您需要在服务器上配置SMTP才能使其正常工作。
You need to configure SMTP on server to make this work.
这篇关于从asp.net页面发送电子邮件的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!