Patch by Thomas Bullinger
Added to the Debian package by Scott Kitterman <scott@kitterman.com>
Since /etc/mailname is Debian (and derivatives) specific, this is best
handled as a distro patch and not upstream.  2012-01-19

Index: postfix-policyd-spf-perl.debian/postfix-policyd-spf-perl
===================================================================
--- postfix-policyd-spf-perl.debian.orig/postfix-policyd-spf-perl	2018-07-29 15:58:57.146462702 -0400
+++ postfix-policyd-spf-perl.debian/postfix-policyd-spf-perl	2018-07-29 15:58:57.142462702 -0400
@@ -45,10 +45,22 @@
     # Makes for a total timeout for UDP queries of 5s * 2 = 10s.
 );
 
+my $MailName = '';
+if (open (MN, '< /etc/mailname'))
+{
+    $MailName = <MN>;
+    close (MN);
+}
+else {
+    $MailName = hostname_long ;
+}
+chomp ($MailName);
+
 # query_rr_type_all will query both type TXT and type SPF. This upstream
 # default is changed due to there being essentiall no type SPF deployment.
 my $spf_server = Mail::SPF::Server->new(
     dns_resolver    => $resolver,
+    hostname => $MailName,
     query_rr_types  => Mail::SPF::Server->query_rr_type_txt,
     default_authority_explanation  =>
     'Please see http://www.openspf.org/Why?s=%{_scope};id=%{S};ip=%{C};r=%{R}'
@@ -100,7 +112,7 @@
 
 # Fully qualified hostname, if available, for use in authentication results
 # headers now provided by the localhost and whitelist checks.
-my  $host = hostname_long;
+my  $host = $MailName;
 
 my %results_cache;  # by message instance
 
