Smtp邮件引发了错误 [英] Smtp mail throuws an error

查看:222
本文介绍了Smtp邮件引发了错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Experts,



祝大家圣诞快乐。

我有一个Web应用程序,我需要使用smtp发送电子邮件。

Hello Experts,

Merry Christmas everyone.
I have a web application, which I need to send an email using smtp.

Protected Sub SendEmail()
        Try
            Dim Client As SmtpClient = New SmtpClient
            Client.EnableSsl = True
            Client.DeliveryMethod = SmtpDeliveryMethod.Network
            Client.UseDefaultCredentials = False
            Client.Host = ""
            Client.Port = "587"

            Dim fromadd As MailAddress = New MailAddress("Su@m.com", "Sushmitha", System.Text.Encoding.UTF8)
            Dim toadd As MailAddress = New MailAddress("Su@m.com", "Sushi", System.Text.Encoding.UTF8)
            Dim msg As MailMessage = New MailMessage(fromadd, toadd)
            msg.Body = "Your information has been submitted successfully! And Here is your Invoice Number: 123. Merry Christmas"
            msg.Subject = " Claim Forms"
            Client.Send(msg)
        Catch ex As Exception

        End Try



    End Sub







我的问题是我发送错误失败。我没有看到这个代码有什么问题。好的我想知道以下事情我开始之前问题

1)什么应该是主持人?是m.com。我的电子邮件是Su@m.com

2)我需要任何设置吗与我的IIS有关吗?

3)我应该怎么做才能检查/获取m.com的IP地址?

4)如何知道是否有任何防火墙都会阻止它。



注意:我正在测试应用程序,因此我添加了来自同一地址。我已经浏览了很多其他网站并且也用谷歌搜索了它但空手而归。

请帮我快速排序这些东西。




And my question is I get an Failure in sending Error. I don't see anything wrong with this code. Ok I wanted to know following things before I start questions
1) what should be Host? is it "m.com". my email is "Su@m.com"
2) Is there any settings I need to do with my IIS?
3) What should I do to check/get the IP address of "m.com"?
4) How to know if there is any Firewall stopping this.

Note: I am testing the application and so I added from and to address same. I have gone through many other websites and also googled it but came empty handed.
Please help me in sorting these things out quickly.

推荐答案

您完全没有运行SMTP服务器的主机名。它与您的电子邮件地址的主机名部分无关。您自己想一想:您在尝试发送邮件时要解决的问题是什么?如果您使用某个可用的邮件客户端发送邮件,您会怎么做?你需要有一些SMTP服务器并知道它的主机名。



-SA
You are totally missing the host name running the SMTP server. It has nothing to do with the host name part of your e-mail address. Think by yourself: what are you addressing to when trying to send a mail? What do you do if you use some available mail client to send your messages? You need to have some SMTP server and know its host name.

—SA


虽然你只是这个工作的新手,我仍然会尝试让你明白这个概念,尽我所能,而不是转发你到MSDN。



1. SMTP服务器主机完全不同,您并不总是使用电子邮件地址的结尾字符来组成SMTP服务器的地址。例如,我的电子邮件地址是justinXXXXX@gmail.com,现在,gmail.com不是我的SMTP服务器的域名。相反,它是smtp.gmail.com。这取决于您的客户端如何允许您使用其服务器向您的客户发送电子邮件。



我曾尝试过Google for m.com,而且我总是收到一个否定回复,即m.com不存在。你在哪里注册?我建议您使用Gmail(Outlook,Yahoo等)服务器发送和接收电子邮件,直到您学习,因为他们为用户免费发送电子邮件预算。



2.不,IIS已设置为允许您使用其配置通过连接的服务器发送电子邮件。哪些是您的用户名,密码和一些其他连接设置,如端口等。您不必为开始付出任何财富,但实际上您只需在构建您的代码时添加它们。



3.您根本不需要其网站或SMTP服务器域的IP地址。您只需输入域名字符串,DNS服务器就会为您完成。



4.这取决于Windows防火墙设置,但通常在通过防火墙发送电子邮件时不会遇到任何麻烦,除非有任何非法活动。



要获得使用VB.NET发送电子邮件的代码示例,请阅读本文档,它将解释核心概念,并将提供一个示例来发送电子邮件。



http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient(ⅴ = vs.110).aspx?cs-save-lang = 1& cs-lang = csharp#code-snippet-2 [ ^ ]
Although you're just a newbie to this job I would still try to make the concept clear to you, as much as I can instead of forwarding you to MSDN.

1. The SMTP server host is totally different, you just don't always use the ending characters of your email-address to make up the SMTP server's address. For example, my email addres is "justinXXXXX@gmail.com", now, "gmail.com" is not my SMTP server's domain name. Instead it is, "smtp.gmail.com". It depends on how your client allows you to use their servers to send emails to your clients.

I have tried to Google for m.com, and I've always recieved a negative response also that m.com doesn't exist. Where did you register yourself? I would like to recommend you to use the Gmail (Outlook, Yahoo etc) servers to send and recieve emails until you're learning because of their free email sending budgets for users.

2. No, IIS is already set to allow you to send the emails through a connected server using their configurations. Which are, your username, password and a few other connection settings such as Port etc. Which you won't have to pay any fortune to get started, but in real you would just add them up while building that code of yours.

3. You do not need the IP address of their website or SMTP server domain at all. You will just input the string of domain name, and the DNS server will do the thing for you.

4. It depends on Windows Firewall settings, but usually you won't get any trouble while sending emails through Firewall unless there is any illegal activity.

To get an example of the code to send an email using VB.NET, please read this document it will explain the core concepts and will provide a sample to send the emails.

http://msdn.microsoft.com/en-us/library/system.net.mail.smtpclient(v=vs.110).aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-2[^]


我解决了这个问题...最初当我有这个问题什么是SMTP主机时,我不知道你一个人可以从你的命令看看SMTP主机提示。终于得到了解决方案......现在发送电子邮件没有错误。以下是更正后的代码。



I solved this... Initially when I had this question what is SMTP host, I have no clue that you alone can look SMTP host from your command prompt. Finally got the solution ... now there is no error in sending email. And Here is the corrected code.

Dim Client As SmtpClient = New SmtpClient
           Client.EnableSsl = False
           Client.DeliveryMethod = SmtpDeliveryMethod.Network
           Client.UseDefaultCredentials = False
           Client.Host = "m.org"
           Client.Port = "25"

           Dim fromadd As MailAddress = New MailAddress("S@m.com", "S", System.Text.Encoding.UTF8)
           Dim toadd As MailAddress = New MailAddress("S@m.com", "S", System.Text.Encoding.UTF8)
           Dim msg As MailMessage = New MailMessage(fromadd, toadd)
           msg.Body = "Your information has been submitted successfully! And Here is your Invoice Number: 123. Merry Christmas"
           msg.Subject = "Claim Forms"
           Client.Send(msg)





但电子邮件位于垃圾文件夹中。是否有我可以将电子邮件直接放在收件箱中的任何方式。



But the Email is sitting in Junk Folder. Is there any way that I can make the email sit directly on Inbox.


这篇关于Smtp邮件引发了错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆