从我的域名在Asp.net中发送电子邮件 [英] Sending Email In Asp.net From my Domain Name

查看:95
本文介绍了从我的域名在Asp.net中发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的精神代码并没有给出任何错误,但在检查收件箱时没有邮件。邮件没有发送,请指导



The below mentined code doesnt gives any error but when checking the inbox there is no mails.i.e the mail is not sent,Please guide

MailMessage Msg = new MailMessage();
        Msg.From = new MailAddress("sales@mydomain.com", "Testing");
        Msg.To.Add(TxtEmail.Text);
        Msg.Subject = "Send Mail with HTML File";
        Msg.Body = myString.ToString();
        SmtpClient client =new SmtpClient();
        client.Host="mail.mydomain.com"; 
        client.Port=25; 
        client.Credentials= new NetworkCredential("sales@mydomain.com","password");
        client.Send(Msg);

推荐答案

这不好:你发给我们的不是你正在使用的代码,别的东西。例如,此行不会编译:

This is not nice: you send us not the code you are using, but something else. For example, this line would not compile:
SmtpClient client = new SmtpClient; // should be: new SmtpClient();





这不是帮助你不可能的。问题是不同的:如果我们帮助,我们应该假设你可以信任。没人想浪费时间。谁知道您的代码中的其他内容与您在帖子中显示的文字有什么不同?如果我们不知道,为什么要浪费时间查看你的代码?



还有另外一个原因就是不认真对待你的问题。如果你真正的代码编译(如你所报告的那样),则意味着它确实存在。你没有打扰复制并正确粘贴它。你对此感到不舒服吗?如果你得到帮助,我们怎么能确定你能够使用它?



如果我不想要的话,我不会花那么多时间写这些帮助。当然,我正在努力帮助,但我想公平地玩。让'尊重彼此'的时间和精力。



至于问题:1)周围有很多代码样本;因此,您始终可以在Web上找到最简单的代码示例,并将代码与它们进行比较; 2)如何确定您的SMPT服务器安装正确且身份验证是否正确?您可以使用任何可用的邮件客户端程序进行检查。



这应该足以让您解决问题。请尝试。



-SA


MailMessage Msg = new MailMessage();

Msg.From =新邮件地址(sales@mydomain.com,测试);

Msg.To.Add(TxtEmail.Text);

Msg.Subject =使用HTML文件发送邮件;

Msg.Body =测试;

SmtpClient客户端=新的SmtpClient();

client.Host =mail.mydomain.com;

client.Port = 25;

client.Credentials = new NetworkCredential(sales @ mydomain。 com,密码);

client.Send(Msg);

上述代码仅适用于.com域名。
MailMessage Msg = new MailMessage();
Msg.From = new MailAddress("sales@mydomain.com", "Testing");
Msg.To.Add(TxtEmail.Text);
Msg.Subject = "Send Mail with HTML File";
Msg.Body = "Test";
SmtpClient client = new SmtpClient();
client.Host = "mail.mydomain.com";
client.Port = 25;
client.Credentials = new NetworkCredential("sales@mydomain.com", "password");
client.Send(Msg);
The above mentioned code works only for .com domains.


您是否符合端口 25已打开?

Smtp 是白名单。

您可以像下面这样配置Smtp。

Have you conform that port 25 is open?
Smtp is white listed.
You can configure Smtp like bellow.
SmtpClient client= new SmtpClient(); 
client.Host = "smtp.live.com"; 
client.Credentials = new NetworkCredential( 
    "myaccount@live.com", "mypassword"); 
client.EnableSsl = true;





但您编码看起来很好。



But you code look fine.


这篇关于从我的域名在Asp.net中发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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