Sending email in aspx

Discussion in 'Email' started by Garry, May 22, 2012.

  1. Sorry for another thread on sending email. I am using the code that you have in your http://support.Winhost.com/KB/a650/h...in-aspnet.aspx

    Of course I changed the domain and password and added some Try Catch code for the error.

    The code works fine as long as I have "[email protected]" as the strTo but anything else, I will get...Mailbox unavailable. The server response was: <[email protected]> No such user here


    Here is the code:

    Dim strFrom = "[email protected]"
    Dim strTo = "[email protected]"
    Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
    MailMsg.BodyEncoding = Encoding.Default
    MailMsg.Subject = "This is a test"
    MailMsg.Body = "This is a sample message using SMTP authentication"
    MailMsg.Priority = MailPriority.High
    MailMsg.IsBodyHtml = True

    'Smtpclient to send the mail message
    Dim SmtpMail As New SmtpClient
    Dim basicAuthenticationInfo As New System.Net.NetworkCredential("[email protected]", "***********")

    SmtpMail.Host = "mail.fofaviation.com"
    SmtpMail.UseDefaultCredentials = False
    SmtpMail.Credentials = basicAuthenticationInfo
    Dim continueUrl As String = ""
    SmtpMail.Send(MailMsg)
    Try
    SmtpMail.Send(MailMsg)
    continueUrl = "~/ThanksForRegistering.aspx"
    Catch ex As Exception
    continueUrl = "~/ErrorRegistering.aspx"

    End Try

    Response.Redirect(continueUrl)
     
    Last edited by a moderator: Oct 14, 2015
  2. You might want to double check your password param, make sure its correct.
     
  3. Is the password that that you are talking about in System.Net.NetworkCredential?

    Dim basicAuthenticationInfo As New System.Net.NetworkCredential("postmaster@fofaviati on.com", "***********")

    I do not have the **** in the actual code. This password is correct.

    Again....As long as I have the email from postmaster and going to postmaster the code works fine.

    Sorry....I am really new to this aspx stuff.

    Thanks
     
  4. It's really indicating bad authentication, you'll be able to send mail to any user within your own domain but not to external server.

    I'd try to reset the password If I were you. Also,did you really spacing your domain name in username param (@fofaviation.com)? If there's white space, authentication will break.
     
  5. No....I did not put a space in the domain name. In the Reply editor it did not have the space....only in the actual post (the one you see now). But bottom line, it is fofaviation.com.

    ok...What password are you referring to? The [email protected] is not the same as the one that I use for the domain (to get into the control panel) because I changed it. Do I need to make them the same?

    I really appreciate the help
    Thanks
     
  6. Well....I went to postmaster and set the password to the domain password and It worked fine....I don't know if it was the act of reseting the password or resetting the password to the domain password....

    Thanks:)
     
  7. The email password of course. That's what you are authenticating with. Well, glad you got it figured out.
     

Share This Page