Solved

Help with "Mailbox unavailable." error

Posted on 2009-06-29
3
501 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
ID: 24737268
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
ID: 24737553
0
 

Author Closing Comment

by:cdemott33
ID: 31597956
Thanks for your help.  Those articles were helpful
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 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