Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

SmtpClient sending emails driectly from own computer

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roger Garrett - 24 Oct 2007 23:25 GMT
I'm trying to usethe C# SmtpClient class to send emails but WITHOUT going
through an SMTP client out on some server. I want to do it directly from my
own machine. I specify localhost and port 80 for the SmtpClient class and it
seems to accept that, in that when I call the Send method it it doesn't
immediately come back with an error or exception, but it ends up throwing a
timeout exception.

I THINK I have the SMTP Virtual Server running on my machine OK, but it's
hard to tell. I came across documentation on installing it (and followed all
the directions) but it also includes notes on running inetmgr, which is on my
machine and registered,  to set up certain settings, but I can't get it to
run.

Any suggestions would be welcome.

- Roger Garrett
sloan - 25 Oct 2007 01:41 GMT
Here are some notes I had in code:

  // see http://www.systemwebmail.com/faq/4.2.3.aspx
  // for common issues
  // Make sure you GRANT relay privledges for "127.0.0.1"

  /*
     *
     * Suggestion 2
     If  you are using "localhost" or "127.0.0.1" as
     the SmtpMail.SmtpServer, you may not have permissions
     to relay through the IIS SMTP Service.
     To allow access, open up the IIS Admin MMC.
     Locate the SMTP Virtual Server, and right-click,
     then select Properties. On the Access tab, click the Relay button.
     In the Relay Restrictions dialog, grant your IP address (127.0.0.1)
     to the Computers listbox. Close down all dialogs,
     and restart the SMTP Service.
     */

  //Also check that the SMTP service is running on your machine.

> I'm trying to usethe C# SmtpClient class to send emails but WITHOUT going
> through an SMTP client out on some server. I want to do it directly from
[quoted text clipped - 17 lines]
>
> - Roger Garrett
Roger Garrett - 25 Oct 2007 03:19 GMT
Sloan,

Thanks for the notes. The problem is, I can't find out how to start up the
IIS Admin MMC. I followed some directions I found on the Internet directing
me to start up inetmgr but it just doesn't seem to exist on my (Windows 2000)
machine.

The instructions I came across at http://support.microsoft.com/kb/308161 
told me how to install IIS and SMTP, which I did. It goes on to say:

"Click Start, point to Programs, point to Administrative Tools, and then
click Internet Services Manager." in order to handle the adminsitraive setup.

But there is NO Adminsitrative Tools item under Start/Programs. Even if I
bring up Control Panel and click the Adminstrative Tools item there, there is
nothing like Internet Services Manager there.

So, how do I determine whether SMTP is running? And how do I start up the
Admin for it? How do I restart SMTP?

- Roger
sloan - 25 Oct 2007 03:25 GMT
You gotta go to

Start  / Settings / Control Panel

Add Remove Software

Windows Components (something like that?)

Then find IIS (Internet Information Services)... and also install the
optional smtp service.

You'll need the Win2000 CD, or a i386 directory from somewhere.

If you don't have those things you're dead in the water.

> Sloan,
>
[quoted text clipped - 21 lines]
>
> - Roger
Roger Garrett - 25 Oct 2007 05:51 GMT
I followed your directions and both IIS and SMTP are already installed.

I'm still stuck with the problem of there being no way to start up the admin
tools. They simply don't show up when I follow the directions at
http://support.microsoft.com/kb/308161.

- Roger

> You gotta go to
>
[quoted text clipped - 36 lines]
> >
> > - Roger
ivar - 25 Oct 2007 06:58 GMT
Hi,

One way is to use some other smtp client, what supports sending emails with
out IIS.

For example see:
http://www.lumisoft.ee/lsWWW/download/downloads/Examples/

smtp client example app, there smtp client can send email message directly
using DNS.

> I'm trying to usethe C# SmtpClient class to send emails but WITHOUT going
> through an SMTP client out on some server. I want to do it directly from
[quoted text clipped - 17 lines]
>
> - Roger Garrett
Jon Skeet [C# MVP] - 25 Oct 2007 08:35 GMT
On Oct 24, 11:25 pm, Roger Garrett
<RogerGarr...@discussions.microsoft.com> wrote:
> I'm trying to usethe C# SmtpClient class to send emails but WITHOUT going
> through an SMTP client out on some server.

You do realise that even if you use your own SMTP server, that's then
just going to talk to another SMTP server, don't you? There may be a
benefit in terms of being able to "fire and forget" the email, letting
the local server take care of retries etc, but there won't be much
more than that.

What are you trying to avoid in not using your "real" SMTP server?
(e.g. the one that your normal mail client connects to)

> I want to do it directly from my own machine. I specify localhost and port 80
> for the SmtpClient class and it seems to accept that

It sounds very unlikely that your SMTP server would be using port 80 -
that's normally for web traffic. Port 25 is much more likely.

Jon
sloan - 25 Oct 2007 10:44 GMT
As Jon as stated, there is no "free lunch".

You'll end up just forwarding it on to a "real" stmp server.
See my notes (previous post) about the relay setup.

See this blog:
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry

There is downloadable code for 1.1 and 2.0.

Test the code against your real isp, or even get a gmail account or
something.

> On Oct 24, 11:25 pm, Roger Garrett
> <RogerGarr...@discussions.microsoft.com> wrote:
[quoted text clipped - 18 lines]
>
> Jon
Roger Garrett - 25 Oct 2007 20:27 GMT
Jon,

Yes, I do understand that the outgoing message goes to an SMTP server on the
receiving end. And I am able to use the SMTP server that's associated with my
email address on my ISP as a relay out to the target server. But what I'm
trying to learn how to do is to use my own computer to send out emails,
without going through a "relay" on my ISP's server.

I've set up IIS and the SMTP Virtual Server on my machine. But I am unable
to run, or even locate, the manager for those in order to configure their
settings so that they will handle my mailing functions (via the SmtpClient
class).

Any help on locating and starting up that manager would be appreciated.

Alternatively, if there's a different C# class that I could use...

I believe that it's possible to send out emails from a home machine, even
without IIS and the SMTP Virtual Server, because I have some software that I
tried out that can do just that. It lets you specify an SMTP server (e.g. my
ISP's server) if you want to use a relay, OR it lets you just do it without a
relay server involved. So it seems it CAN be done. I just can't figure out
how.

- Roger

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.