在服务器上部署时,未在C#中使用SMTP发送电子邮件 [英] Email not sent using SMTP in C# when deployed on server

查看:83
本文介绍了在服务器上部署时,未在C#中使用SMTP发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Web API中使用以下代码发送电子邮件并部署在服务器上,但邮件没有发送并且抛出错误

I have used the below code in Web API to send an email and deployed on server but mail didn't dispatched and was throwing an error

代码:

string toAddress =
" test@adc.com" +
"," +
" test@adc.com " ;

stringtoAddress = "test@adc.com"+ ","+ "test@adc.com";

     ;           

               

string fromAddress =
" test@adc.com " ;

stringfromAddress = "test@adc.com";

 

string mesg =
" Hello";

            

            

MailMessage msg =
new MailMessage (fromAddress,
toAddress,
"引发了DeviceID的硬件请求:"
mesg);

MailMessagemsg = newMailMessage(fromAddress, toAddress, "has raised the hardware request for DeviceID : ", mesg);

                msg.CC.Add (

                msg.CC.Add(

new MailAddress " test@adc.com " ));

newMailAddress("test@adc.com"));

                System.Net.Mail。

                System.Net.Mail.

SmtpClient emailClient =
new SmtpClient " host
details"
) ;

SmtpClientemailClient = newSmtpClient("host details");

                 msg.IsBodyHtml =

                msg.IsBodyHtml =

true ;

true;

                 emailClient.Credentials =

                emailClient.Credentials =

CredentialCache 。DefaultNetworkCredentials;

CredentialCache.DefaultNetworkCredentials;

                 emailClient.DeliveryMethod = System.Net.Mail。

                emailClient.DeliveryMethod = System.Net.Mail.

SmtpDeliveryMethod 。网络;

SmtpDeliveryMethod.Network;

                 emailClient.Send(msg);

                emailClient.Send(msg);

错误

Error

邮箱不可用。服务器是:5.7.60 SMTP ;客户无权作为此发件人发送

Mailbox unavailable. The server was: 5.7.60 SMTP; Client does not have permission to send as this sender

任何人都可以在这方面帮助我,并提前致谢。

Can any one please help me in this regard and thanks in advance.

问候,

Rajeswari

Rajeswari

推荐答案

您好
Rajeswari Addepalli,

我可以看到您使用SMTP发送邮件。

I can see that you are using SMTP to send mail.

On是论坛,我们只提供对VSTO相关问题的支持。

On this forum, We only provide support for VSTO related issue.

从帖子的描述来看,您的问题看起来与VSTO无关。

From the description of the thread, It looks like your issue is not related with VSTO.

为了更好地响应您的问题并提供更好的解决方案,我将此线程移至MSDN C#论坛。

So for better response and better solution for your issue, I move this thread to MSDN C# Forum.

我们建议适当发布的原因是您将获得最合格的池受访者以及定期阅读论坛的其他合作伙伴可以分享他们的知识,也可以从与我们的互动中学习。

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

感谢您的理解。

问候,

Deepak


这篇关于在服务器上部署时,未在C#中使用SMTP发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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