Solved

Error while sending email using Mail.NET via smtp

Posted on 2008-06-26
4
657 Views
Last Modified: 2013-11-30
I get the following message while trying to instantiate and send an email.  I've hidden the actual pwd/user/domain for obvious reasons but have verified with the admin that they are accurate.  I'm using my own local domain email address and trying to test sending to hotmail/yahoo account. Any suggestions would be appreciated.

"mailbox unavailable. The server response was 5.7.1 unable to relay for" the hotmail email address I;m testing


public Email()

    {

        SmtpClient smtpClient = new SmtpClient(smtpAdd);

        MailMessage message = new MailMessage(messageFrom, messageTo, subject, body);

        //smtpClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;

        smtpClient.UseDefaultCredentials = false;

        NetworkCredential credential = new NetworkCredential(username,password,domain);

        //smtpClient.Credentials = credential;

        //smtpClient.Credentials = CredentialCache.DefaultNetworkCredentials;

        

        smtpClient.Send(message);

    }

Open in new window

0
Comment
Question by:abedeenf
4 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
0
 
LVL 4

Accepted Solution

by:
antioed earned 250 total points
Comment Utility
Either your credentials are not authenticating Exchange properly or you are instantiating from a remote host that is not permitted "relay".  I am guessing the former since I have run into this before.  Not sure about the exact programmatic Mail.Net syntax required but it might just be that you need to format the credentials so they are passed  in <domain>\<user> format.
0
 

Expert Comment

by:Sha_Sha_In
Comment Utility
Hi,

If you are stillfacing problem, follow these steps one by one, your problem will be resolved,

1.      Open IIS (Start-> Run -> Type inetmgr -> Click OK)
    1.1.      Web_Server_Machine_Name -> Default SMTP Virtual Server -> Properties
    1.2.      Select Security Tab -> In Operators section, Administrators should exist, otherwise Add Administrators group.
    1.3.      Select Access Tab -> Click on Relay -> Select only the list below option -> If 127.0.0.1 does not exists, follow these steps,
            1.3.1.      Click on Add -> Select Single Computer
            1.3.2.      Type 127.0.0.1 in IP address
            1.3.3.      Click on OK -> Click on OK
    1.4.      Select Access Tab -> Click on Authentication
            1.4.1.      Uncheck Anonymous access
            1.4.2.      Check Integrated Windows Authentication
            1.4.3.      Click on OK
    1.5.      Select Delivery Tab -> Click on Advanced -> Provide following values in fields,
            1.5.1.      Maximum hop count - 15
            1.5.2.      Full-qualified domain name - Web_Server_Machine_Name.domain.local (Whatever it is...)
            1.5.3.      Smart host - SMTP_Server_Machine_Name.domain.local (Whatever it is...)
            1.5.4.      Check Attempt direct delivery before sending to smart host checkbox
            1.5.5.      Uncheck Perform reverse DNS lookup on incoming messages checkbox
            1.5.6.      Click on OK  -> Click on Apply -> Click on OK
2.      Restart IIS (Start-> Run -> Type iisreset -> Click OK)
3.      Give write access permissions on "C:\Inetpub\mailroot" folder to the appropriate user depending on operating system type,
            For Windows XP/2000 Permissions - Web_Server_Machine_Name\ASPNET
            For Windows 2003 Server Permissions - NETWORK Service

Regards,
Sha_Sha_In
0
 

Author Closing Comment

by:abedeenf
Comment Utility
Thanks for pointing me in the right direction!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
This video discusses moving either the default database or any database to a new volume.

763 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

10 Experts available now in Live!

Get 1:1 Help Now