Solved

Help with "Mailbox unavailable." error

Posted on 2009-06-29
3
500 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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
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…

809 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