Proofpoint.SecureEmailRelay.Mail 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Proofpoint.SecureEmailRelay.Mail --version 1.0.2
                    
NuGet\Install-Package Proofpoint.SecureEmailRelay.Mail -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Proofpoint.SecureEmailRelay.Mail" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Proofpoint.SecureEmailRelay.Mail" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Proofpoint.SecureEmailRelay.Mail" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Proofpoint.SecureEmailRelay.Mail --version 1.0.2
                    
#r "nuget: Proofpoint.SecureEmailRelay.Mail, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Proofpoint.SecureEmailRelay.Mail@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Proofpoint.SecureEmailRelay.Mail&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Proofpoint.SecureEmailRelay.Mail&version=1.0.2
                    
Install as a Cake Tool

Proofpoint Secure Email Relay Mail API Package

NuGet Downloads

This library implements all the functions of the SER Email Relay API via C#.

Requirements

  • .NET 6.0+
  • HttpClient (built-in in .NET)
  • Active Proofpoint SER API credentials

Installing the Package

You can install the library using NuGet:

# Using .NET CLI
dotnet add package Proofpoint.SecureEmailRelay.Mail

# Using NuGet Package Manager
Install-Package Proofpoint.SecureEmailRelay.Mail

Features

  • Send Emails: Easily compose and send emails with minimal code.
  • Support for Attachments:
    • Attach files from disk
    • Encode attachments as Base64
    • Send byte[] attachments
  • Support for Inline HTML Content:
    • Using the syntax <img src="cid:logo">
    • Content-ID can be set manually or auto-generated
  • HTML & Plain Text Content: Supports both plain text and HTML email bodies.
  • Recipient Management: Add To, CC, and BCC recipients with ease.
  • Reply Management: Add Reply-To addresses to redirect replies.

Quick Start

using Proofpoint.SecureEmailRelay.Mail;

class Program
{
    static async Task Main()
    {
        var client = new Client("<client_id>", "<client_secret>");

        // Create a new Message object
        var message = new Message("This is a test email", new MailUser("sender@example.com", "Joe Sender"));

        // Add text content body
        message.AddContent(new Content("This is a test message", ContentType.Text));

        // Add HTML content body, with embedded image
        message.AddContent(new Content("<b>This is a test message</b><br><img src=\"cid:logo\">", ContentType.Html));

        // Create an inline attachment from disk and set the cid
        message.AddAttachment(Attachment.FromFile("C:/temp/logo.png", Disposition.Inline, "logo"));

        // Add recipients
        message.AddTo(new MailUser("recipient1@example.com", "Recipient 1"));
        message.AddTo(new MailUser("recipient2@example.com", "Recipient 2"));

        // Add CC
        message.AddCc(new MailUser("cc1@example.com", "CC Recipient 1"));
        message.AddCc(new MailUser("cc2@example.com", "CC Recipient 2"));

        // Add BCC
        message.AddBcc(new MailUser("bcc1@example.com", "BCC Recipient 1"));
        message.AddBcc(new MailUser("bcc2@example.com", "BCC Recipient 2"));

        // Add attachments
        message.AddAttachment(Attachment.FromBase64("VGhpcyBpcyBhIHRlc3Qh", "test.txt"));
        message.AddAttachment(Attachment.FromFile("C:/temp/file.csv"));
        message.AddAttachment(Attachment.FromBytes(new byte[] { 1, 2, 3 }, "bytes.txt", "text/plain"));

        // Set Reply-To
        message.AddReplyTo(new MailUser("noreply@proofpoint.com", "No Reply"));

        // Send the email
        var result = await client.Send(message);

        Console.WriteLine($"HTTP Response: {result.HttpResponse.StatusCode}/{(int)result.HttpResponse.StatusCode}");
        Console.WriteLine($"Reason: {result.Reason}");
        Console.WriteLine($"Message ID: {result.MessageId}");
        Console.WriteLine($"Request ID: {result.RequestId}");
    }
}

Attachment MIME Type Deduction Behavior

  • When creating attachments, the library automatically determines the MIME type based on the file extension.
  • If the MIME type cannot be determined, an exception is raised.
// Create an attachment from disk; the MIME type will be "text/csv", and disposition will be "Disposition.Attachment"
Attachment.FromFile("C:/temp/file.csv");

// This will throw an error, as the MIME type is unknown
Attachment.FromFile("C:/temp/file.unknown");

// Create an attachment and specify the type information. The disposition will be "Disposition.Attachment", filename will be unknown.txt, and MIME type "text/plain"
Attachment.FromFile("C:/temp/file.unknown", filename: "unknown.txt");

// Create an attachment and specify the type information. The disposition will be "Disposition.Attachment", filename will be file.unknown, and MIME type "text/plain"
Attachment.FromFile("C:/temp/file.unknown", mimeType: "text/plain");

Inline Attachments and Content-IDs

When creating attachments, they are Disposition.Attachment by default. To properly reference a Content-ID (e.g., <img src="cid:logo">), you must explicitly set the attachment disposition to Disposition.Inline. If the attachment type is set to Disposition.Inline, a default unique Content-ID will be generated.

Using a Dynamically Generated Content-ID

var logo = Attachment.FromFile("C:/temp/logo.png", Disposition.Inline);
message.AddContent(new Content($"<b>Test</b><br><img src=\"cid:{logo.ContentId}\">", ContentType.Html));
message.AddAttachment(logo);

Setting a Custom Content-ID

message.AddAttachment(Attachment.FromFile("C:/temp/logo.png", Disposition.Inline, "logo"));
message.AddContent(new Content("<b>Test</b><br><img src=\"cid:logo\">", ContentType.Html));

Proxy Support

Proofpoint.SecureEmailRelay.Mail supports HTTP and HTTPS proxies by allowing users to pass a custom HttpClientHandler when initializing the Client.

To configure an HTTP(S) proxy, create a custom HttpClientHandler and pass it to the client:

using System.Net;
using Proofpoint.SecureEmailRelay.Mail;

// Configure an HTTP/HTTPS proxy
var proxy = new WebProxy("http://your-proxy-server:port")
{
    Credentials = new NetworkCredential("your-username", "your-password") // Optional authentication
};

var httpClientHandler = new HttpClientHandler
{
    Proxy = proxy,
    UseProxy = true // Ensures proxy usage
};

// Initialize the client with proxy support
Client client = new("<client_id>", "<client_secret>", httpClientHandler);

Known Issues

There is a known issue where empty file content results in a 400 Bad Request error.

{
  "content": "",
  "disposition": "attachment",
  "filename": "empty.txt",
  "id": "1ed38149-70b2-4476-84a1-83e73913d43c",
  "type": "text/plain"
}

🔹 API Response:

Status Code: 400/BadRequest
Reason: attachments[0].content is required
Message ID:
Request ID: fe9a1acf60a20c9d90bed843f6530156
Raw JSON: {"request_id":"fe9a1acf60a20c9d90bed843f6530156","reason":"attachments[0].content is required"}

This issue has been reported to Proofpoint Product Management.

Limitations

  • The Proofpoint API currently does not support empty file attachments.
  • If an empty file is sent, you will receive a 400 Bad Request error.

Additional Resources

For more information, refer to the official Proofpoint Secure Email Relay API documentation:
API Documentation

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 529 2/24/2025
1.0.2 245 2/6/2025 1.0.2 is deprecated because it is no longer maintained.