Link to home
Start Free TrialLog in
Avatar of abedeenf
abedeenf

asked on

Error while sending email using Mail.NET via smtp

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

Avatar of Éric Moreau
Éric Moreau
Flag of Canada image

ASKER CERTIFIED SOLUTION
Avatar of antioed
antioed

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
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
Avatar of abedeenf
abedeenf

ASKER

Thanks for pointing me in the right direction!