Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

web.config SMTP Issues

Status
Not open for further replies.

LittlBUGer

Programmer
Apr 26, 2006
81
US
Hello all. I'm having some ASP.NET 2.0 emailing issues that I can't seem to figure out. When I first began programming a new website, which started using ASP.NET user authentication controls and registration to a MS SQL DB, all was fine. Meaning, with the details I put in for the web.config SMTP section, when a new user registered it would properly email them their details, etc. Now a month or so later, after I haven't changed anything in the web.config file, the emails don't work anymore. I even tested by making a simple "Contact Us" page and dynamically made it send an email, and it says it worked, but there's no email. I'm pretty positive the mail account that I'm using on our server is good, as I can login and it gets and sends email, so I'm kind of stuck on what's going on. Any suggestions? My web.config code for that section is below:

Code:
	<system.net>
		<mailSettings>
      <smtp deliveryMethod="Network" from="blah@blah.com">
				<network port="25"  host="blahmail" password="blahpass" userName="blahuser" />
			</smtp>
		</mailSettings>
	</system.net>

And the code for the ContactUs page is below:

Code:
    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient

        Dim Mailmsg As New System.Net.Mail.MailMessage
        Mailmsg.To.Clear()
        Mailmsg.To.Add(New System.Net.Mail.MailAddress("MBN <blah@blah.com>"))
        If cbSendCopy.Checked = True Then
            Mailmsg.Bcc.Add(New System.Net.Mail.MailAddress(tbName.Text & " <" & tbEmail.Text & ">"))
        End If
        Mailmsg.From = New System.Net.Mail.MailAddress(tbName.Text & " <" & tbEmail.Text & ">")
        Mailmsg.Subject = tbSubject.Text
        Try
            Mailmsg.Body = tbMessage.Text
            obj.Send(Mailmsg)
            lblMessage.ForeColor = Drawing.Color.Green
            lblMessage.Text = "Message sent successfully!"
            tbName.Text = ""
            tbEmail.Text = ""
            tbSubject.Text = ""
            tbMessage.Text = ""
            cbSendCopy.Checked = False
        Catch ex As Exception
            lblMessage.ForeColor = Drawing.Color.Red
            lblMessage.Text = "Error! Email Send Failed! - " & ex.Message
        End Try
    End Sub

Thanks. :)

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein
 
If you haven't changed any of your code and it once worked then it's unlikely to be an ASP.NET issue. Try asking in the relevant windows forum to see if anyone can help verify the SMTP installation.


-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Do you have full access to the box this is on?
From the server,

Start > Run > cmd
telnet mail.yourdomainnamehere.com 25

if it doesnt connect, your mail host and/or ISP blocked port 25
 
Sorry I didn't reply to this earlier, but I got it figured out. The account I was using to connect to the server originally had an email account associated with it, but then another admin removed it for some reason. Once I put it back, all was fine. Thanks.

"Only two things are infinite, the universe and human stupidity, and I'm not sure about the former." - Albert Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top