C# SMTP email sending code fails for Yahoo Mail but works fine for other servers, can anyone help? -


i using code send smtp email via yahoo smtp server, personal project writing.

using system.net.mail; using system.net;  smtpclient theclient = new smtpclient("smtp.mail.yahoo.com", 465); theclient.usedefaultcredentials = false; theclient.credentials = new networkcredential("username", "password"); theclient.enablessl = true;  mailmessage themessage = new mailmessage("username@yahoo.com",                                           "to.someone@gmail.com");  themessage.subject = "dave test c# subject"; themessage.body = "dave test c# body";  theclient.send(themessage); 

it's pretty standard code sending smtp email, but... server seems throw error. forcibly terminates connection. not happen if use other smtp servers gmail, windows live or various other isp smtp servers.

this exception , stack trace:

system.io.ioexception: unable read data transport connection: existing connection forcibly closed remote host. @ system.net.mail.smtpclient.send(mailmessage message) @ consoleapplication1.program.main(string[] args) in e:\dev\arcsoftware.ftpprocessor\consoleapplication1\program.cs:line 28 

i know problem not environmental though can send same server these exact settings using outlook express. wondering if need send certificate or something?

if you, or know has ideas appreciate help.

it's not supported through 465, following post details workaround

how can send emails through ssl smtp .net framework?

update: link details why might work through outlook express, not through system.net.mail

http://blogs.msdn.com/b/webdav_101/archive/2008/06/02/system-net-mail-with-ssl-to-authenticate-against-port-465.aspx


Comments

Popular posts from this blog

linux - Mailx and Gmail nss config dir -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -