in reply to Re: How to send mail (with attachments) from a Winx64 box
in thread How to send mail (with attachments) from a Winx64 box

Even better. To get the mailserver, something like this (with your added sanity and error-checking):

use strict; use Net::DNS; my ($domain) = $email_to =~ /@(.*)$/; my ($mailserver) = map { $_->exchange } sort { $a->preference <=> $b-> +preference } mx($domain);

This gets the most preferred mailserver. Alternately, you might want to loop the array by preference, exiting on success.