Click here to Skip to main content
15,881,630 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Comments
Kuthuparakkal 17-Feb-15 22:50pm    
You need to set EnableSsl property to true.

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.
 
Share this answer
 
You need to set EnableSsl property to true.
C#
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);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900