如何通过联系我们页面发送邮件? [英] How to send mail in contact us page through?

查看:237
本文介绍了如何通过联系我们页面发送邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用所有代码但发生异常以下..

SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要身份验证。了解更多信息



我尝试了什么:



i试用了以下代码...

但它会给出以下异常

SMTP服务器需要安全连接或客户端未经过身份验证。服务器响应为:5.5.1需要验证了解更多信息

I use all code but exception occured Following..
The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at

What I have tried:

i tried follwing code...
but it will give following exception
"The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at"

try
            {
                System.Net.Mail.MailMessage Msg = new System.Net.Mail.MailMessage();
                // Sender e-mail address.
                Msg.From = new MailAddress(txtEmail.Text);
                // Recipient e-mail address.
               Msg.To.Add("administrator@aspdotnet-suresh.com");
            
                Msg.Subject = txtSubject.Text;
                Msg.Body = txtmsg.Text;
                // your remote SMTP server IP.
                SmtpClient smtp = new SmtpClient();
                smtp.Host = "smtp.gmail.com";
                smtp.Port = 587;
                //smtp.Credentials = new System.Net.NetworkCredential("yourgmailemail@gmail.com", "yourpassword");
                
                smtp.EnableSsl = true;
                smtp.Send(Msg);
                //Msg = null;
                success.Text = "Thanks for Contact us";
                // Clear the textbox valuess
                txtname.Text = "";
                txtSubject.Text = "";
                txtmsg.Text = "";
                txtEmail.Text = "";
            }
            catch (Exception ex)
            {
              // Console.WriteLine("{0} Exception caught.", ex);
            }

推荐答案

您不提供电子邮件服务器所需的身份验证 - 您的用户名和密码!

大多数电子邮件服务器都需要登录以防止自己被用作spambot未经授权的人或流氓代码。



这是我使用的代码:使用或不使用附件在C#中发送电子邮件:通用例程。 [ ^ ]
You don't provide the authentication the email server needs - your username and password!
Most email servers require login to prevent themselves being used as a spambot by unauthorized persons or "rogue code".

Here's the code I use: Sending an Email in C# with or without attachments: generic routine.[^]


这篇关于如何通过联系我们页面发送邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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