Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending mail without installing an SMTP server

Tags:

c#

.net

email

smtp

I have a .Net application. I want this application to send an email to me. How do I implement this without installing an SMTP server?

like image 279
Germstorm Avatar asked Mar 12 '09 09:03

Germstorm


People also ask

Do all emails use SMTP?

It is also the only dedicated protocol for sending emails. Most email clients—including Outlook, Apple Mail, Gmail, and Yahoo Mail—rely on SMTP to “push” or send messages from a sender to a recipient.

Can Gmail use SMTP without authentication?

Use the restricted Gmail SMTP server This option lets you send messages to Gmail or Google Workspace users only. This option doesn't require you to authenticate, and you can't send messages to people outside your organization.

Can I create my own SMTP server?

When it comes to building an SMTP server, there are a couple of routes that you can take. You can use a hosted SMTP relay service that provides scalable email relaying capabilities right out of the box. Or you can setup your own SMTP server, by building on top of an open source SMTP server solution.


3 Answers

Using an SmtpClient to send a MailMessage does not require you to have a server on your local machine.

Your e-mail service provider is the one with the server (e.g. smtp.gmail.com), and your SmtpClient talks to it.

like image 89
Daniel LeCheminant Avatar answered Oct 24 '22 06:10

Daniel LeCheminant


This article by Peter Bromberg on eggheadcafe.com

C# SMTP Mail without SMTP Service or CDO

explains how to send email without relying on an SMTP client:

Sending email via TCP using the native SMTP RFC commands "HELO", "MAIL From", RCPT TO", etc. is no big deal. That's one of the first tricks we learn with Telnet. Finding or writing managed code that will do so reliably is another story. The code in the class that follows is not my original code - I've cobbled it together from three different sample sources, fixing namespaces, error handling, and other minor items, changing console code to class library code, and providing a complete Winforms - based test harness front end that illustrates its correct usage.

I've also included sample code to correctly process and add a mail attachment via an OpenFileDialog here. This code MIME encodes and transmits the attachment(s) according to the specification.

like image 23
splattne Avatar answered Oct 24 '22 08:10

splattne


You can't send email without the services of a SMTP server, there is of course no need for you to install one, just point your code at your ISPs SMTP server or your companies Exchange server (or what ever they use).

like image 24
AnthonyWJones Avatar answered Oct 24 '22 06:10

AnthonyWJones