Automated delivery test for mail server

Everyday I have to test the delivery capacity from my mailserver to big providers like gmail, yahoo, hotmail etc.

So I wrote a script for the purpose of automated delivery test.

First I put the big providers in a txt file, which looks like:

 xxx@gmail.com
xxx@hotmail.com
xxx@yahoo.com
xxx@icloud.com
xxx@aol.com
xxx@gmx.com
xxx@fastmail.com
...

Each line in the file is a recepient email address.

Then I have the following perl script for sending email from localhost.

 #!/usr/bin/perl
use strict;
use Email::Send::YYClouds;

my $email = shift || die "$0 email\n";

my $msg = Email::Send::YYClouds->new();
$msg->send(recepient => [$email],
sender => 'sender@your_domain.tld',
smtprelay => '127.0.0.1',
subject => 'delivery capacity testing',
body => 'message body here...',
);

The final is a shell script which looks like:

 #!/bin/bash

cat providers.txt |while read LINE;do perl checkmail.pl $LINE;done
sleep 15
cat providers.txt |while read LINE;do echo $LINE; sudo tail -100 /var/log/mail.log|grep $LINE|grep 'status=sent';echo "---------";done

And the run results would be similar as follows.

 xxx@Hotmail.com
Nov 30 19:09:55 mail postfix/smtp[735760]: 253F4AE1D: to=<xxx@Hotmail.com>, relay=hotmail-com.olc.protection.outlook.com[104.47.59.161]:25, delay=0.88, delays=0.02/0.05/0.14/0.66, dsn=2.6.0, status=sent (250 2.6.0 <20221201030954.253F4AE1D@mail.domain.com> [InternalId=8456790607690, Hostname=MWHPR0601MB3643.namprd06.prod.outlook.com] 10129 bytes in 0.261, 37.772 KB/sec Queued mail for delivery -> 250 2.1.5)
---------
xxx@Yahoo.com
Nov 30 19:09:55 mail postfix/smtp[735762]: 6AF0EAE1F: to=<xxx@Yahoo.com>, relay=mta7.am0.yahoodns.net[98.136.96.77]:25, delay=0.74, delays=0.04/0.05/0.36/0.29, dsn=2.0.0, status=sent (250 ok dirdel)
---------
xxx@iCloud.com
Nov 30 19:09:56 mail postfix/smtp[735758]: B55D6972E: to=<xxx@iCloud.com>, relay=mx02.mail.iCloud.com[17.57.155.34]:25, delay=1.8, delays=0.02/0/0.27/1.5, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as A6B5A15C0099)

So you have a rough view on if email were delivered successfully to those big providers.