diff --git a/Mailosaur.Test/EmailsTests.cs b/Mailosaur.Test/EmailsTests.cs index 03c2bf5..8d4acce 100644 --- a/Mailosaur.Test/EmailsTests.cs +++ b/Mailosaur.Test/EmailsTests.cs @@ -247,6 +247,43 @@ public void SpamAnalysisTest() Assert.NotEmpty(rule.Description); } } + + [Fact] + public void DeliverabilityReportTest() + { + var targetId = this.fixture.emails[0].Id; + DeliverabilityReport result = this.fixture.client.Analysis.Deliverability(targetId); + + Assert.NotNull(result); + Assert.NotNull(result.Spf); + Assert.NotEmpty(result.Dkim); + foreach (var dkim in result.Dkim) + { + Assert.NotNull(dkim); + } + Assert.NotNull(result.Dmarc); + + Assert.NotNull(result.BlockLists); + foreach (var blockList in result.BlockLists) + { + Assert.NotNull(blockList.Id); + Assert.NotNull(blockList.Name); + } + + Assert.NotNull(result.Content); + + Assert.NotNull(result.DnsRecords); + Assert.NotNull(result.DnsRecords.A); + Assert.NotNull(result.DnsRecords.MX); + Assert.NotNull(result.DnsRecords.PTR); + + Assert.NotNull(result.SpamAssassin); + foreach (SpamAssassinRule rule in result.SpamAssassin.Rules) + { + Assert.NotEmpty(rule.Rule); + Assert.NotEmpty(rule.Description); + } + } [Fact] public void DeleteTest() diff --git a/Mailosaur/Models/BlockListResult.cs b/Mailosaur/Models/BlockListResult.cs new file mode 100644 index 0000000..d0b7bc1 --- /dev/null +++ b/Mailosaur/Models/BlockListResult.cs @@ -0,0 +1,9 @@ +namespace Mailosaur.Models +{ + public class BlockListResult + { + public string Id { get; set; } + public string Name { get; set; } + public ResultEnum Result { get; set; } + } +} \ No newline at end of file diff --git a/Mailosaur/Models/Content.cs b/Mailosaur/Models/Content.cs new file mode 100644 index 0000000..45a7c78 --- /dev/null +++ b/Mailosaur/Models/Content.cs @@ -0,0 +1,15 @@ +namespace Mailosaur.Models +{ + public class Content + { + public bool Embed { get; set; } + public bool Iframe { get; set; } + public bool Object { get; set; } + public bool Script { get; set; } + public bool ShortUrls { get; set; } + public int TextSize { get; set; } + public int TotalSize { get; set; } + public bool MissingAlt { get; set; } + public bool MissingListUnsubscribe { get; set; } + } +} \ No newline at end of file diff --git a/Mailosaur/Models/DeliverabilityReport.cs b/Mailosaur/Models/DeliverabilityReport.cs new file mode 100644 index 0000000..be70f30 --- /dev/null +++ b/Mailosaur/Models/DeliverabilityReport.cs @@ -0,0 +1,15 @@ +using System.Collections.Generic; + +namespace Mailosaur.Models +{ + public class DeliverabilityReport + { + public EmailAuthenticationResult Spf { get; set; } + public List Dkim { get; set; } + public EmailAuthenticationResult Dmarc { get; set; } + public List BlockLists { get; set; } + public Content Content { get; set; } + public DnsRecords DnsRecords { get; set; } = new DnsRecords(); + public SpamAssassinResult SpamAssassin { get; set; } + } +} \ No newline at end of file diff --git a/Mailosaur/Models/DnsRecords.cs b/Mailosaur/Models/DnsRecords.cs new file mode 100644 index 0000000..7f520d8 --- /dev/null +++ b/Mailosaur/Models/DnsRecords.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Mailosaur.Models +{ + public class DnsRecords + { + public List A { get; set; } + public List MX { get; set; } + public List PTR { get; set; } + } +} \ No newline at end of file diff --git a/Mailosaur/Models/EmailAuthenticationResult.cs b/Mailosaur/Models/EmailAuthenticationResult.cs new file mode 100644 index 0000000..6047589 --- /dev/null +++ b/Mailosaur/Models/EmailAuthenticationResult.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; + +namespace Mailosaur.Models +{ + public class EmailAuthenticationResult + { + public ResultEnum Result { get; set; } + public String Description { get; set; } + public string RawValue { get; set; } + public Dictionary Tags { get; set; } = new Dictionary(); + } +} \ No newline at end of file diff --git a/Mailosaur/Models/ResultEnum.cs b/Mailosaur/Models/ResultEnum.cs new file mode 100644 index 0000000..1e65fcf --- /dev/null +++ b/Mailosaur/Models/ResultEnum.cs @@ -0,0 +1,10 @@ +namespace Mailosaur.Models +{ + public enum ResultEnum + { + Pass, + Warning, + Fail, + Timeout + } +} \ No newline at end of file diff --git a/Mailosaur/Models/SpamAssassinResult.cs b/Mailosaur/Models/SpamAssassinResult.cs new file mode 100644 index 0000000..792a243 --- /dev/null +++ b/Mailosaur/Models/SpamAssassinResult.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace Mailosaur.Models +{ + public class SpamAssassinResult + { + public int Score { get; set; } + public ResultEnum Result { get; set; } + public List Rules { get; set; } + } +} \ No newline at end of file diff --git a/Mailosaur/Operations/Analysis.cs b/Mailosaur/Operations/Analysis.cs index 384de61..d2a1bb2 100644 --- a/Mailosaur/Operations/Analysis.cs +++ b/Mailosaur/Operations/Analysis.cs @@ -37,5 +37,29 @@ public SpamAnalysisResult Spam(string email) /// public Task SpamAsync(string email) => ExecuteRequest(HttpMethod.Get, $"api/analysis/spam/{email}"); + + /// + /// Perform a deliverability test + /// + /// + /// Perform deliverability testing on the specified email + /// + /// + /// The identifier of the email to be analyzed. + /// + public DeliverabilityReport Deliverability(string email) + => Task.Run(async () => await DeliverabilityAsync(email)).Result; + + /// + /// Perform a deliverability test + /// + /// + /// Perform deliverability testing on the specified email + /// + /// + /// The identifier of the email to be analyzed. + /// + public Task DeliverabilityAsync(string email) + => ExecuteRequest(HttpMethod.Get, $"api/analysis/deliverability/{email}"); } }