Asp.net 网站电子邮件错误

发布于 2024-11-19 03:02:56 字数 2087 浏览 1 评论 0原文

我创建了一个简单的联系表单...当我单击发送按钮时,它将信息提交给我

这是问题,我的代码在本地服务器上运行正常。但它不运行 在实时服务器(Godaddy 服务器)上它给出异常

这是代码:

Imports System.IO
Imports System.Net.Mail
Partial Class Contact_Form_Demo
Inherits System.Web.UI.UserControl

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim fileName As String = Server.MapPath("~/App_Data/ContactForm.txt")
    Dim mailBody As String = File.ReadAllText(fileName)

    mailBody = mailBody.Replace("##Name##", TextBox1.Text)
    mailBody = mailBody.Replace("##Email##", TextBox2.Text)
    mailBody = mailBody.Replace("##HomePhone##", TextBox3.Text)
    mailBody = mailBody.Replace("##BusinessPhone##", TextBox4.Text)
    mailBody = mailBody.Replace("##Comments##", TextBox5.Text)

    Dim mymessage As MailMessage = New MailMessage()
    mymessage.Subject = "Response from web site"
    mymessage.Body = mailBody

    mymessage.From = New MailAddress("Email Here", "Tuhin Bhatt")
    mymessage.To.Add(New MailAddress("My Email Here", "Tuhin Bhatt"))

    Dim mysmtpclient As SmtpClient = New SmtpClient()
    mysmtpclient.Send(mymessage)
End Sub
End Class

这是我在实时服务器上收到的错误:

Server Error in '/' Application.
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 74.125.95.109:25
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.Net.Sockets.SocketException: 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 74.125.95.109:25
Source Error:  
Line 26:  
Line 27:         Dim mysmtpclient As SmtpClient = New SmtpClient()  
Line 28:         mysmtpclient.Send(mymessage)  
Line 29:     End Sub  
Line 30: End Class

I Have Created a Simple Contact Form... That submits the information to me When i click on the send button

Here is the Problem that i have the code runs alright on the local server. But it does not run
on a live server(Godaddy server) It Gives Exception

Here is the code:

Imports System.IO
Imports System.Net.Mail
Partial Class Contact_Form_Demo
Inherits System.Web.UI.UserControl

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim fileName As String = Server.MapPath("~/App_Data/ContactForm.txt")
    Dim mailBody As String = File.ReadAllText(fileName)

    mailBody = mailBody.Replace("##Name##", TextBox1.Text)
    mailBody = mailBody.Replace("##Email##", TextBox2.Text)
    mailBody = mailBody.Replace("##HomePhone##", TextBox3.Text)
    mailBody = mailBody.Replace("##BusinessPhone##", TextBox4.Text)
    mailBody = mailBody.Replace("##Comments##", TextBox5.Text)

    Dim mymessage As MailMessage = New MailMessage()
    mymessage.Subject = "Response from web site"
    mymessage.Body = mailBody

    mymessage.From = New MailAddress("Email Here", "Tuhin Bhatt")
    mymessage.To.Add(New MailAddress("My Email Here", "Tuhin Bhatt"))

    Dim mysmtpclient As SmtpClient = New SmtpClient()
    mysmtpclient.Send(mymessage)
End Sub
End Class

This is the Error I get on live server:

Server Error in '/' Application.
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 74.125.95.109:25
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
Exception Details: System.Net.Sockets.SocketException: 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 74.125.95.109:25
Source Error:  
Line 26:  
Line 27:         Dim mysmtpclient As SmtpClient = New SmtpClient()  
Line 28:         mysmtpclient.Send(mymessage)  
Line 29:     End Sub  
Line 30: End Class

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

日裸衫吸 2024-11-26 03:02:56

您的托管环境不允许您使用 Web.config 中指定的设置访问 SMTP 服务器。如果您的 web.config 文件中没有 部分,则意味着您的应用程序正在尝试访问 GoDaddy 的 machine.config 文件指定的设置。而且很可能,您无权访问该特定服务器和端口。

请在此处查看如何设置邮件设置部分。并使用您正在管理的网站的 SMTP 服务器的名称和密码。

Your hosted environment does not allow you access to the SMTP Server with the settings specified in your Web.config. If you don't have a <mailSettings> section in your web.config file, that means that your application is attempting to access the settings specified by GoDaddy's machine.config file. And very likely, you're not allowed access to that particular server and port.

Take a look at how to set up your MailSettings section here. And use a name and password to the SMTP server for the website you're administering.

一直在等你来 2024-11-26 03:02:56
Dim mysmtpclient As SmtpClient = New SmtpClient() 

除非您出于隐私原因省略它,否则您的 SmtpClinet() 会丢失一些参数,即邮件服务器和端口。

Dim mysmtpclient As SmtpClient = New SmtpClient() 

Unless you are omitting it for privacy reasons, your SmtpClinet() is missing some arquments, namely the mail server and ports.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文