asp.net - Error Failure Sending Mail -
i trying send email using asp.net vb. email send through company server. have many suggestion internet error same. 'failure sending mail'
here code far:
protected sub btnsend_click(sender object, e eventargs) handles btnsend.click try dim message new mailmessage() dim client new smtpclient("blablabla@myhost.com") message.from = new mailaddress(txtfrom.text) message.to.add(new mailaddress(txtto.text)) message.subject = txtsubject.text message.body = txtmessage.text message.isbodyhtml = true message.priority = mailpriority.high client.port = 25 client.enablessl = true client.send(message) lblinfo.visible = true lblinfo.text = "your message has been sent" catch ex exception lblinfo.visible = true lblinfo.text = ex.message end try end sub
and here web.config
<system.net> <mailsettings> <smtp deliverymethod ="network" from="myemailaddress.com"> <network host="localhost" port="25" defaultcredentials ="true" /> </smtp> </mailsettings>
i tried change enablessl = false, still give me same error.
thanks in advances.
to find exact cause of smtp error, should test smtp server manually using telnet. first, make sure telnet client installed (hint: "turn windows features on , off") start command prompt , type following:
> telnet my.servername.com 25 [enter]
you should welcome message server. type following commands, 1 @ time , pressing [enter] after each line. substitute , addresses accordingly. not type '>' character, represents prompt:
> helo > mail from: user@sending-domain.com > rcpt to: user@recipient-domain.com > data > subject: test > test text goes in body > .
you either message mail queued delivery, in case error lies elsewhere in program, or error message can troubleshoot. causes relaying denied, server unavailable, mailbox full, user doesn't exist, etc.
ps, don't need use built in telnet client, can use other telnet client (ex: putty) if prefer.
Comments
Post a Comment