Getting error while sending email through SMTP

I am getting following error message while sending email through SMTP service:

I have following SMTP setting on my system:

Operating system: Windows 7 Home Premium

IIS: IIS 7

How can i resolve this problem?

Thanks.

Answers


Based on the inner exception and your code, you're trying to send mail via 127.0.0.1.

Removing the line in your code that is setting the smtp host to 127.0.0.1 should cause the site to use the SMTP settings as defined in IIS.

As SMTP settings will usually vary in between server setups, live / test environments, it is usually best to not hard-code SMTP settings such as Host in your code and instead to set the settings via IIS (which actually takes from web.config's section system.net/mailSettings).

Edit:

As your web.config doesn't have a mailSettings section, I would assume you took the screenshot from the SMTP Email in IIS7 in the server view. There's a similar section in the website view.

You can manually add the mailSettings to the web.config: I usually do so.

For your setup (ie, storing emails as file in a directory), the following would be needed:

  <system.net>
    <mailSettings>
      <smtp deliveryMethod="specifiedPickupDirectory">
        <specifiedPickupDirectory pickupDirectoryLocation="c:\inetpub" />
      </smtp>
    </mailSettings>
  </system.net>

Note that this wouldn't send emails, but just store them in the folder for a SMTP server to pick them up. To send them, you'll need to setup a SMTP server or connect to a third party one like http://sendgrid.com.


I would suggest you look at the exception detail, including any inner exception. To hazard a guess, maybe you don't have permission to write to C:\Inetpub.


Need Your Help

JQM 1.1 - data-rel=back only in the same domain?

mobile jquery-mobile

jQuery Mobile (at least 1.1) provides a nice feature that is a "go back" button. According to the chapter "Back button link" in the docs, adding data-rel="back" on a link/button will simulate the e...

Enabling Replay mechanism with camel from messages from DB

apache-camel activemq

Iam trying to implement replay mechanisam with camel ie., i will have to retrieve all the messages already persisted and forward to appropriate camel route to reprocess.This will be triggred by qua...