Did you get an exit value other than 0? Did you get any
warnings from mailx? What's the content of your
mailer log (/var/log/mail.log or something like
that)?
A message of "it's not being sent" doesn't give us much
clues on what could be wrong. Specially not because the
most likely cause is a non-Perl one.