Link to home
Start Free TrialLog in
Avatar of cdemott33
cdemott33Flag for United States of America

asked on

Help with "Mailbox unavailable." error

Hi Experts -

I'm trying to send an email via an asp.net script and I'm getting the following error.

Mailbox unavailable. The server response was: 5.7.1 Relaying to <johnsmith@gmail.com> denied (authentication required)

Can someone please tell me what I'm doing wrong?  

PS:  My script ONLY works if I'm sending the message to someone WITHIN my domain.  Anyone on the outside my domain (i.e. HotMail, Gmail, Yahoo, etc.) will throw this error.


' Create the MailMessage instance
        Dim mail As New MailMessage()
 
        ' FROM:
        mail.From = New MailAddress("confirmation@mycompany.com", "Company Solutions")
 
        ' TO:
        mail.To.Add(strEmailAddress)
 
        ' SUBJECT & BODY
        mail.Subject = MailSubject
        mail.Body = mailText
        mail.IsBodyHtml = True
 
        ' Create the SmtpClient object
        Dim smtp As New SmtpClient
 
        '(4) Send the MailMessage (use the Web.config settings)
        smtp.Send(mail)

Open in new window

Avatar of Geoff Bryan
Geoff Bryan
Flag of United Kingdom of Great Britain and Northern Ireland image

It sounds like you need to provide some specific details to your mail server.

Try adding the 2 new lines shown in the attatched snippet.


 Create the MailMessage instance
        Dim mail As New MailMessage()
 
        ' FROM:
        mail.From = New MailAddress("confirmation@mycompany.com", "Company Solutions")
 
        ' TO:
        mail.To.Add(strEmailAddress)
 
        ' SUBJECT & BODY
        mail.Subject = MailSubject
        mail.Body = mailText
        mail.IsBodyHtml = True
 
        ' Create the SmtpClient object
        Dim smtp As New SmtpClient
'New lines        
 
smtp.Host = "mail.yourdomain.com'
smtp.Credentials = New Net.NetworkCredential(YourLoginName,YourPassword)
 
'to here 
        '(4) Send the MailMessage (use the Web.config settings)
        smtp.Send(mail)
 

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of raja_ind82
raja_ind82
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cdemott33

ASKER

Thanks for your help.  Those articles were helpful