简体   繁体   English

vb.net从IIS发送Smtp邮件FormatException

[英]vb.net Send Smtp Mail From IIS FormatException

Well i got a page that sends emails and everything runs fine in the developer web server but when i publish to a IIS Server i get a FormatException when i try to send the mail.... ex.Message = "the specified string is not in the form required for an e-mail address." 好吧,我有一个发送电子邮件的页面,并且在开发人员Web服务器上一切正常,但是当我发布到IIS服务器时,当我尝试发送邮件时,我得到了FormatException。...ex.Message =“指定的字符串不是以电子邮件地址所需的形式。”

the email is in this sample someone@gmail.com 该示例中的电子邮件地址为someone@gmail.com

Im using the "SmtpClient" and the "MailMessage" classes to send mails.. 我使用“ SmtpClient”和“ MailMessage”类发送邮件。

And the server runs windows server 2003 服务器运行Windows Server 2003

Edit: Im using same smtp settings on the Dev Webserver as im doing in IIS. 编辑:我在Dev Web服务器上使用与IIS中相同的smtp设置。

Check that you've enabled local email relaying for the SMTP service on your Windows Server 2003 box. 检查是否在Windows Server 2003框中启用了SMTP服务的本地电子邮件中继。 By 'local' I mean that applications on your local machine can use the SMTP service to relay emails - but you almost certainly don't want to allow external connections to do the same. “本地”是指您本地计算机上的应用程序可以使用SMTP服务来中继电子邮件-但是您几乎可以肯定不希望外部连接执行相同的操作。

Make sure you don't have any invisible whitespace around your email address. 确保您的电子邮件地址周围没有任何空白。 For example, if you are getting the email from a database, or input control, try trimming it, like: 例如,如果要从数据库或输入控件中获取电子邮件,请尝试对其进行修整,例如:

mail.To.Add( New MailAddress( txtEmailAddress.Text.Trim() ) )

如果有人遇到此问题,解决方案是不要使用MailMessage的空构造函数!!!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM