Solved

Help with "Mailbox unavailable." error

Posted on 2009-06-29
3
498 Views
Last Modified: 2012-05-07
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

0
Comment
Question by:cdemott33
3 Comments
 
LVL 4

Expert Comment

by:vbgb
Comment Utility
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

0
 
LVL 14

Accepted Solution

by:
raja_ind82 earned 500 total points
Comment Utility
0
 

Author Closing Comment

by:cdemott33
Comment Utility
Thanks for your help.  Those articles were helpful
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now