summaryrefslogtreecommitdiffstats
path: root/SendGrid/SendGridMail
diff options
context:
space:
mode:
Diffstat (limited to 'SendGrid/SendGridMail')
-rwxr-xr-xSendGrid/SendGridMail/ISendGrid.cs13
-rwxr-xr-xSendGrid/SendGridMail/SendGrid.cs23
-rwxr-xr-xSendGrid/SendGridMail/Transport/ITransport.cs5
-rwxr-xr-xSendGrid/SendGridMail/Transport/REST.cs3
-rwxr-xr-xSendGrid/SendGridMail/Transport/SMTP.cs4
5 files changed, 25 insertions, 23 deletions
diff --git a/SendGrid/SendGridMail/ISendGrid.cs b/SendGrid/SendGridMail/ISendGrid.cs
index 3be707f..08d109c 100755
--- a/SendGrid/SendGridMail/ISendGrid.cs
+++ b/SendGrid/SendGridMail/ISendGrid.cs
@@ -1,11 +1,7 @@
using System;
using System.Collections.Generic;
-using System.IO;
-using System.Linq;
using System.Net;
using System.Net.Mail;
-using System.Net.Mime;
-using System.Text;
namespace SendGridMail
{
@@ -219,10 +215,13 @@ namespace SendGridMail
/// </summary>
/// <param name="text">String for the plain text email body showing what you want the message to look like.</param>
/// <param name="html">String for the HTML email body showing what you want the message to look like.</param>
+ void EnableUnsubscribe(String text, String html);
+
+ /// <summary>
+ /// Allow's SendGrid to manage unsubscribes and ensure these users don't get future emails from the sender
+ /// </summary>
/// <param name="replace">Tag in the message body to be replaced with the unsubscribe link and message</param>
- /// <param name="url">URL for a landing page, if you have your own prepared</param>
- /// <param name="landing">HTML body of a landing page created by SendGrid for you</param>
- void EnableUnsubscribe(String text, String html, String replace, String url, String landing);
+ void EnableUnsubscribe(String replace);
/// <summary>
/// Attaches a message at the footer of the email
diff --git a/SendGrid/SendGridMail/SendGrid.cs b/SendGrid/SendGridMail/SendGrid.cs
index 4b91dfc..59d7976 100755
--- a/SendGrid/SendGridMail/SendGrid.cs
+++ b/SendGrid/SendGridMail/SendGrid.cs
@@ -30,7 +30,7 @@ namespace SendGridMail
/// Creates an instance of SendGrid's custom message object
/// </summary>
/// <returns></returns>
- public static SendGrid GenerateInstance()
+ public static SendGrid GetInstance()
{
var header = new Header();
return new SendGrid(header);
@@ -48,7 +48,7 @@ namespace SendGridMail
/// <param name="text">the plain text part of the message</param>
/// <param name="transport">Transport class to use for sending the message</param>
/// <returns></returns>
- public static SendGrid GenerateInstance(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
+ public static SendGrid GetInstance(MailAddress from, MailAddress[] to, MailAddress[] cc, MailAddress[] bcc,
String subject, String html, String text, TransportType transport)
{
var header = new Header();
@@ -394,7 +394,7 @@ namespace SendGridMail
Header.AddFilterSetting(filter, new List<string> { "url" }, url);
}
- public void EnableUnsubscribe(string text, string html, string replace, string url, string landing)
+ public void EnableUnsubscribe(string text, string html)
{
var filter = _filters["Unsubscribe"];
@@ -410,10 +410,15 @@ namespace SendGridMail
Header.Enable(filter);
Header.AddFilterSetting(filter, new List<string> { "text/plain" }, text);
- Header.AddFilterSetting(filter, new List<string> { "text/html" }, html);
- Header.AddFilterSetting(filter, new List<string> { "replace"}, replace);
- Header.AddFilterSetting(filter, new List<string> { "url"}, url);
- Header.AddFilterSetting(filter, new List<string> { "landing" }, landing);
+ Header.AddFilterSetting(filter, new List<string> {"text/html"}, html);
+ }
+
+ public void EnableUnsubscribe(string replace)
+ {
+ var filter = _filters["Unsubscribe"];
+
+ Header.Enable(filter);
+ Header.AddFilterSetting(filter, new List<string> { "replace" }, replace);
}
public void EnableFooter(string text = null, string html = null)
@@ -506,7 +511,7 @@ namespace SendGridMail
/// Helper function lets us look at the mime before it is sent
/// </summary>
/// <param name="directory">directory in which we store this mime message</param>
- internal void SaveMessage(String directory)
+ public void SaveMessage(String directory)
{
var client = new SmtpClient("localhost")
{
@@ -523,7 +528,7 @@ namespace SendGridMail
switch (Transport)
{
case TransportType.SMTP:
- transport = SMTP.GenerateInstance(credentials);
+ transport = SMTP.GetInstance(credentials);
break;
case TransportType.REST:
transport = REST.GetInstance(credentials);
diff --git a/SendGrid/SendGridMail/Transport/ITransport.cs b/SendGrid/SendGridMail/Transport/ITransport.cs
index 26fccf4..b3a1936 100755
--- a/SendGrid/SendGridMail/Transport/ITransport.cs
+++ b/SendGrid/SendGridMail/Transport/ITransport.cs
@@ -1,7 +1,8 @@
namespace SendGridMail.Transport
{
/// <summary>
- ///
+ /// Encapsulates the transport mechanism so that it can be used in a generic way,
+ /// regardless of the transport type
/// </summary>
public interface ITransport
{
@@ -11,4 +12,4 @@
/// <param name="message">the message to be delivered</param>
void Deliver(ISendGrid message);
}
-}
+} \ No newline at end of file
diff --git a/SendGrid/SendGridMail/Transport/REST.cs b/SendGrid/SendGridMail/Transport/REST.cs
index 7b8c361..0370b42 100755
--- a/SendGrid/SendGridMail/Transport/REST.cs
+++ b/SendGrid/SendGridMail/Transport/REST.cs
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
-using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
@@ -20,9 +19,7 @@ namespace SendGridMail.Transport
public const String JsonFormat = "json";
public const String XmlFormat = "xml";
- private readonly List<KeyValuePair<String, String>> _query;
private readonly NetworkCredential _credentials;
- private readonly NameValueCollection _queryParameters;
private readonly String _restEndpoint;
private readonly String _format;
#endregion
diff --git a/SendGrid/SendGridMail/Transport/SMTP.cs b/SendGrid/SendGridMail/Transport/SMTP.cs
index 606afcd..a878ce8 100755
--- a/SendGrid/SendGridMail/Transport/SMTP.cs
+++ b/SendGrid/SendGridMail/Transport/SMTP.cs
@@ -72,7 +72,7 @@ namespace SendGridMail.Transport
/// <param name="credentials">Sendgrid user credentials</param>
/// <param name="host">MTA recieving this message. By default, sent through SendGrid.</param>
/// <param name="port">SMTP port 25 is the default. Port 465 can be used for Secure SMTP.</param>
- public static SMTP GenerateInstance(NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
+ public static SMTP GetInstance(NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
{
var client = new SmtpWrapper(host, port, credentials, SmtpDeliveryMethod.Network);
return new SMTP(client, credentials, host, port);
@@ -86,7 +86,7 @@ namespace SendGridMail.Transport
/// <param name="host"></param>
/// <param name="port"></param>
/// <returns></returns>
- internal static SMTP GenerateInstance(ISmtpClient client, NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
+ internal static SMTP GetInstance(ISmtpClient client, NetworkCredential credentials, String host = SmtpServer, Int32 port = Port)
{
return new SMTP(client, credentials, host, port);
}