Sending mail without installing an SMTP server

后端 未结 3 1598
野的像风
野的像风 2020-12-01 08:20

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?

3条回答
  •  Happy的楠姐
    2020-12-01 09:00

    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.

提交回复
热议问题