Skip to content

Commit 6bd6f15

Browse files
authored
Introduced deliverability reporting request/models
1 parent f433ef8 commit 6bd6f15

File tree

3 files changed

+237
-1
lines changed

3 files changed

+237
-1
lines changed

src/mailosaurCommands.d.ts

Lines changed: 185 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,180 @@ export interface SpamAnalysisResult {
513513
score?: number;
514514
}
515515

516+
/**
517+
* The results of deliverability report performed by Mailosaur.
518+
*/
519+
export interface DeliverabilityReport {
520+
/**
521+
* The result of checking for SPF issues
522+
*/
523+
spf?: EmailAuthenticationResult;
524+
/**
525+
* The result of checking for DKIM issues
526+
*/
527+
dkim?: EmailAuthenticationResult[];
528+
/**
529+
* The result of checking for DMARC issues
530+
*/
531+
dmarc?: EmailAuthenticationResult;
532+
/**
533+
* The result of each blocklist that was checked
534+
*/
535+
blockLists?: BlockListResult[];
536+
/**
537+
* The result of content checks made on the email
538+
*/
539+
content?: Content;
540+
/**
541+
* The DNS records checks made against the sender's domain
542+
*/
543+
dnsRecords?: DnsRecords;
544+
/**
545+
* The result of spam analysis performed by Mailosaur
546+
*/
547+
spamAssassin?: SpamAssassinResult;
548+
}
549+
550+
/**
551+
* The result of an email domain check
552+
*/
553+
export interface EmailAuthenticationResult {
554+
/**
555+
* The result of the check
556+
*/
557+
result?: ResultEnum;
558+
/**
559+
* A description of any issue/notes found
560+
*/
561+
description?: string;
562+
/**
563+
* The raw values returned from the check
564+
*/
565+
rawValue?: string;
566+
/**
567+
* The seperated tags returned from the check
568+
*/
569+
tags?: { [key: string]: string};
570+
}
571+
572+
/**
573+
* The result of an domain check against a blocklist checker
574+
*/
575+
export interface BlockListResult{
576+
/**
577+
* The identifier of the blocklist
578+
*/
579+
id: string;
580+
/**
581+
* The name of the blocklist
582+
*/
583+
name: string;
584+
/**
585+
* The result of the blocklist check
586+
*/
587+
result: ResultEnum;
588+
}
589+
590+
/**
591+
* The results of email content analysis
592+
*/
593+
export interface Content{
594+
/**
595+
* The content contained embed tags
596+
*/
597+
embed: boolean;
598+
/**
599+
* The content contained Iframe tags
600+
*/
601+
iframe: boolean;
602+
/**
603+
* The content contained object tags
604+
*/
605+
object: boolean;
606+
/**
607+
* The content contained script tags
608+
*/
609+
script: boolean;
610+
/**
611+
* The content contained URL's that have been shortened
612+
*/
613+
shortUrls: boolean;
614+
/**
615+
* The length of all text that the content contained
616+
*/
617+
textSize: number;
618+
/**
619+
* The length of all HTML that the content contained
620+
*/
621+
totalSize: number;
622+
/**
623+
* Image(s) were missing "alt" properties
624+
*/
625+
missingAlt: boolean;
626+
/**
627+
* The message is missing a "List-Unsubscribe" header
628+
*/
629+
missingListUnsubscribe: boolean;
630+
}
631+
632+
/**
633+
* The records found when checking DNS records of an email sender's domain
634+
*/
635+
export interface DnsRecords{
636+
/**
637+
* The A Records of the sender's domain
638+
*/
639+
a?: string[];
640+
/**
641+
* The MX Records of the sender's domain
642+
*/
643+
mx?: string[];
644+
/**
645+
* The PTR Record of the sender's domain
646+
*/
647+
ptr?: string[];
648+
}
649+
650+
/**
651+
* The results of spam assassin check performed by Mailosaur.
652+
*/
653+
export interface SpamAssassinResult{
654+
/**
655+
* Overall Mailosaur spam score.
656+
*/
657+
score: number;
658+
/**
659+
* The result of the spam check
660+
*/
661+
result: ResultEnum;
662+
/**
663+
* Spam Assassin filter rules.
664+
*/
665+
rules: SpamAssassinRule[];
666+
}
667+
668+
/**
669+
* The result of a deliverability check
670+
*/
671+
export enum ResultEnum {
672+
/**
673+
* The check had a positive result
674+
*/
675+
Pass,
676+
/**
677+
* The check was acceptable but could be improved
678+
*/
679+
Warning,
680+
/**
681+
* The check had a negative result
682+
*/
683+
Fail,
684+
/**
685+
* The check was inconclusive due to a timeout
686+
*/
687+
Timeout
688+
}
689+
516690
/**
517691
* The detail of an individual account limit.
518692
*/
@@ -1023,7 +1197,17 @@ declare global {
10231197
* The identifier of the message to be analyzed.
10241198
*/
10251199
messageId: string
1026-
): Chainable<SpamAnalysisResult>;
1200+
): Cypress.Chainable<SpamAnalysisResult>;
1201+
1202+
/**
1203+
* Perform a deliverability report of an email.
1204+
*/
1205+
mailosaurGetDeliverabilityReport(
1206+
/**
1207+
* The identifier of the message to be analyzed.
1208+
*/
1209+
messageId: string
1210+
): Cypress.Chainable<DeliverabilityReport>;
10271211

10281212
/**
10291213
* Generates a random email address by appending a random string in front of the server's

src/mailosaurCommands.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class MailosaurCommands {
2828
'mailosaurDownloadAttachment',
2929
'mailosaurDownloadMessage',
3030
'mailosaurGetSpamAnalysis',
31+
'mailosaurGetDeliverabilityReport',
3132
'mailosaurGenerateEmailAddress',
3233
'mailosaurGetUsageLimits',
3334
'mailosaurGetUsageTransactions',
@@ -220,6 +221,10 @@ class MailosaurCommands {
220221
return this.request.get(`api/analysis/spam/${messageId}`);
221222
}
222223

224+
mailosaurGetDeliverabilityReport(messageId) {
225+
return this.request.get(`api/analysis/deliverability/${messageId}`);
226+
}
227+
223228
mailosaurGenerateEmailAddress(serverId) {
224229
const host = Cypress.env('MAILOSAUR_SMTP_HOST') || 'mailosaur.net';
225230
const random = (Math.random() + 1).toString(36).substring(7);

test/react-app/cypress/e2e/messages.cy.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,53 @@ describe('Mailosaur message commands', () => {
327327
});
328328
});
329329
});
330+
331+
describe('.mailosaurGetDeliverabilityReport', () => {
332+
it('should perform a deliverability report on an email', (done) => {
333+
const targetId = emails[0].id;
334+
cy.mailosaurGetDeliverabilityReport(targetId).then((result) => {
335+
336+
expect(result).to.be.ok;
337+
338+
result.dkim.forEach((dkim) => {
339+
expect(dkim.result).to.be.ok;
340+
expect(dkim.tags).to.be.ok;
341+
});
342+
343+
expect(result.dmarc).to.be.ok;
344+
expect(result.dmarc.result).to.be.ok;
345+
expect(result.dmarc.tags).to.be.ok;
346+
347+
expect(result.blockLists).to.be.ok;
348+
result.blockLists.forEach((blockList) => {
349+
expect(blockList.result).to.be.ok;
350+
expect(blockList.id).to.be.ok;
351+
expect(blockList.name).to.be.ok;
352+
});
353+
354+
expect(result.content).to.be.ok;
355+
expect(result.content.embed).to.be.a('boolean');
356+
expect(result.content.iframe).to.be.a('boolean');
357+
expect(result.content.object).to.be.a('boolean');
358+
expect(result.content.script).to.be.a('boolean');
359+
expect(result.content.shortUrls).to.be.a('boolean');
360+
expect(result.content.totalSize).to.be.ok;
361+
expect(result.content.textSize).to.be.ok;
362+
expect(result.content.missingAlt).to.be.a('boolean');
363+
expect(result.content.missingListUnsubscribe).to.be.a('boolean');
364+
365+
expect(result.dnsRecords).to.be.ok;
366+
367+
expect(result.spamAssassin).to.be.ok;
368+
result.spamAssassin.rules.forEach((rule) => {
369+
expect(rule.score).to.be.a('number');
370+
expect(rule.rule).to.be.ok;
371+
expect(rule.description).to.be.ok;
372+
});
373+
done();
374+
});
375+
});
376+
});
330377

331378
describe('.mailosaurDeleteMessage', () => {
332379
it('should delete an email', (done) => {

0 commit comments

Comments
 (0)