从网页发送电子邮件 [英] Sending Email from web page
本文介绍了从网页发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
此错误来.....
-------------------------------------------------- --------------
This error Comes.....
----------------------------------------------------------------
System.Net.Mail.SmtpException was caught
Message="Failure sending mail."
Source="System"
StackTrace:
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at SendEmail.SendMail() in d:\AMS\Addmission_Managment_System\SendEmail.aspx.cs:line 45
InnerException: System.Net.WebException
Message="Unable to connect to the remote server"
Source="System"
StackTrace:
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.GetConnection()
at System.Net.Mail.SmtpClient.Send(MailMessage message)
InnerException: System.Net.Sockets.SocketException
Message="No connection could be made because the target machine actively refused it 173.194.79.109:587"
Source="System"
ErrorCode=10061
NativeErrorCode=10061
StackTrace:
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
InnerException:
这是我使用的代码
This is Code which I Using
public void SendMail()
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add("bhulku.niravvasoya@gmail.com");
mail.From = new MailAddress("bhulku.niravvasoya@gmail.com", txtfrom.Text);
mail.Subject = txtsubject.Text;
mail.Body = txtmessage.Text;
SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.EnableSsl = true;
smtp.Port = 587;
System.Net.NetworkCredential yetki = new NetworkCredential("bhulku.niravvasoya@gmail.com", "123abc");
smtp.Credentials = yetki;
smtp.Send(mail);
Response.Write("mailiniz başarılı bir şekilde gönderilmiştir");
}
catch (Exception e)
{
Response.Write(e.Message);
}
}
然后在web.config文件中写入任何内容....?
AND any thing write in web.config file.....?
推荐答案
检查以下几点:
1-检查该端口587是否在您的计算机上打开
2-检查您的防病毒软件是否阻止了与端口的连接
Check the following points:
1- Check that this port 587 is open on your machine
2- Check if your antivirus is blocking the connection to your port
您好,
阅读以上异常中的消息.
Message =无法连接到远程服务器"
Message =无法建立连接,因为目标计算机主动拒绝它173.194.79.109:587"
可能由于以下原因之一
您可能正在从可能已终止gmail连接的PC上访问gmail,即任一防火墙都可能阻止了您对gmail的访问.或连接可能已超时.
看看.
Hi,
Read the message in the above exception.
Message="Unable to connect to the remote server"
Message="No connection could be made because the target machine actively refused it 173.194.79.109:587"
It can be either due to the following reasons
Either u may be accessing the gmail from a pc to which the gmail connection may have been terminated ie either firewall may be blocking your access to gmail. Or connection may have been timed out.
Check it out.
查看异常消息,它清楚地表明无法建立连接,因为目标计算机主动拒绝了它173.194.79.109:587".因此,请尝试在服务器上为端口587启用入站和出站规则.
您可以从本文中找到帮助.
http://www.windowsnetworking.com/articles_tutorials/configure-Windows-Server-2008-advanced-firewall-MMC-snap-in.html [
Hi,
Look at the exception message, it clearly says "No connection could be made because the target machine actively refused it 173.194.79.109:587". So try enabling inbound and outbound rules for port 587 on the server.
You can find help from this article.
http://www.windowsnetworking.com/articles_tutorials/configure-Windows-Server-2008-advanced-firewall-MMC-snap-in.html[^]
这篇关于从网页发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文