如何通过tls(vb,net或c#)发送电子邮件 [英] How send email over tls (vb,net or c#)
问题描述
嗨
i尝试从我的组织电子邮件服务器发送电子邮件,
i得到此错误:拒绝中继访问
我的服务器管理员告诉我:第一次登录进入服务器
我的电子邮件服务器端口是587.
我是怎么回事可以通过vb.net或c#中的tls协议发送电子邮件吗?
查看:
检查weather@irimo.ir
在域名irimo.ir上查找MX主机
mail.irimo.ir(首选项:10)
在mail.irimo.ir上尝试TLS [185.14.80.133](10):
秒测试阶段和结果
[000.255]已连接到服务器
[001.148]< - 220 mail.irimo.ir ESMTP Postfix
[001.148]我们被允许连接
[ 001.148] - GT; EHLO checktls.com
[001.391]< - 250-mail.irimo.ir
250-PIPELINING
250-SIZE 15728640
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
[001.391]我们可以使用此服务器
[001.392] TLS是此服务器上的一个选项
[001.392] - > STARTTLS
[001.626]< - 220 2.0.0准备启动TLS
[001.626] STARTTLS命令在此服务器上运行
[ 002.131]密码使用:DHE-RSA-AES256-SHA
[002.131]连接转换为SSL
[002.181]
证书1链中3:
subject = / C = IR / ST = TH / O = Touca Collaboration Suite / OU = Touca Collaboration Suite / CN = mail.irimo.ir
issuer = / C = IR / ST = TH / L = TH / O = Touca Collaboration Suite / OU = Touca Collaboration Suite / CN = mail.irimo.ir
[002.229]
链中的证书2 of 3:
subject = / C = IR / ST = TH / O = Touca Collaboration Suite / OU = Touca Collaboration Suite / CN = mail.irimo.ir
issuer = / C = IR / ST = TH / L = TH / O = Touca Collaboration Suite / OU = Touca Collaboration Suite / CN = mail.irimo.ir
[002.277]
证书3 of 3 in chain:
subject = / C = IR / ST = TH / O = Touca Collaboration Suite / OU = Touca Collaboration Suite / CN = mail.irimo.ir
issuer = / C = IR / ST = TH / L = TH / O = Touca Collaboration Suite / OU = Touca Collaboration Suite / CN = mail.irimo.ir
[002.278]证书未经证实:无法获得本地发行人证书
[002.278]这可能会有所帮助:什么是中级证书>
[002.278]因此电子邮件已加密但域名未经验证
[002.279]证书主机名已验证(mail.irimo.ir = mail.irimo.ir)
[002.279] ~~> EHLO checktls.com
[002.662]< ~~ 250-mail.irimo.ir
250-PIPELINING
250-SIZE 15728640
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH = PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
[002.662] TLS在此服务器上成功启动
[002.662] ~~> MAIL FROM:< test@checktls.com>
[004.496]< ~~ 250 2.1.0 Ok
[004.496]发件人可以
[004.497] ~~> RCPT TO:< weather@irimo.ir>
[006.386]< ~~ 250 2.1.5 Ok
[006.387]收件人确定,电子邮件地址打样
[006.387] ~~>退出
[006.713]< ~~ 221 2.0.0再见
Hi
i try to send email from my organization email server,
i get this error: relay access denied
and my server administrator tell me: first log in to server
my email server port is 587.
how i can send email over tls protocol in vb.net or c#?
check tls out:
Checking weather@irimo.ir
looking up MX hosts on domain "irimo.ir"
mail.irimo.ir (preference:10)
Trying TLS on mail.irimo.ir[185.14.80.133] (10):
seconds test stage and result
[000.255] Connected to server
[001.148] <-- 220 mail.irimo.ir ESMTP Postfix
[001.148] We are allowed to connect
[001.148] --> EHLO checktls.com
[001.391] <-- 250-mail.irimo.ir
250-PIPELINING
250-SIZE 15728640
250-VRFY
250-ETRN
250-STARTTLS
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
[001.391] We can use this server
[001.392] TLS is an option on this server
[001.392] --> STARTTLS
[001.626] <-- 220 2.0.0 Ready to start TLS
[001.626] STARTTLS command works on this server
[002.131] Cipher in use: DHE-RSA-AES256-SHA
[002.131] Connection converted to SSL
[002.181]
Certificate 1 of 3 in chain:
subject= /C=IR/ST=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
issuer= /C=IR/ST=TH/L=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
[002.229]
Certificate 2 of 3 in chain:
subject= /C=IR/ST=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
issuer= /C=IR/ST=TH/L=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
[002.277]
Certificate 3 of 3 in chain:
subject= /C=IR/ST=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
issuer= /C=IR/ST=TH/L=TH/O=Touca Collaboration Suite/OU=Touca Collaboration Suite/CN=mail.irimo.ir
[002.278] Cert NOT VALIDATED: unable to get local issuer certificate
[002.278] this may help: What Is An Intermediate Certificate
[002.278] So email is encrypted but the domain is not verified
[002.279] Cert Hostname VERIFIED (mail.irimo.ir = mail.irimo.ir)
[002.279] ~~> EHLO checktls.com
[002.662] <~~ 250-mail.irimo.ir
250-PIPELINING
250-SIZE 15728640
250-VRFY
250-ETRN
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
[002.662] TLS successfully started on this server
[002.662] ~~> MAIL FROM:<test@checktls.com>
[004.496] <~~ 250 2.1.0 Ok
[004.496] Sender is OK
[004.497] ~~> RCPT TO:<weather@irimo.ir>
[006.386] <~~ 250 2.1.5 Ok
[006.387] Recipient OK, E-mail address proofed
[006.387] ~~> QUIT
[006.713] <~~ 221 2.0.0 Bye
推荐答案
见这里:
https ://technet.microsoft.com/en-gb/library/cc784450(v = ws.10).aspx
您在尝试访问域时是否在域中进行了身份验证运行你的代码......这是我的问题。
see here :
https://technet.microsoft.com/en-gb/library/cc784450(v=ws.10).aspx
are you authenticated in the domain when trying to run your code....this was my issue.
你需要将EnableSsl属性设置为true。
You need to set EnableSsl property to true.
SmtpClient client = new SmtpClient(exchangeServer, 587);
client.Credentials = new System.Net.NetworkCredential(username, password);
client.EnableSsl = true; //This is the you need to do
client.Send(msg);
这篇关于如何通过tls(vb,net或c#)发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!