#!/usr/bin/perl use strict; use warnings; use Mail::Sender; #-1 = $smtphost unknown #-2 = socket() failed #-3 = connect() failed #-4 = service not available #-5 = unspecified communication error #-6 = local user $to unknown on host $smtp #-7 = transmission of message failed #-8 = argument $to empty #-9 = no message specified in call to MailMsg or MailFile #-10 = no file name specified in call to SendFile or MailFile #-11 = file not found #-12 = not available in singlepart mode #-13 = site specific error #-14 = connection not established. Did you mean MailFile instead of SendFile? #-15 = no SMTP server specified #-16 = no From: address specified #-17 = authentication protocol not accepted by the server #-18 = login not accepted #-19 = authentication protocol is not implemented my @recipients = qw(ich@xyz.de); sub send_mail { my $msg = "msg\n"; my $topic = "topic"; foreach my $recipient (@recipients) { my $sender = new Mail::Sender{ from => 'hallo@xyz.de', to => $recipient, smtp => 'abc.de.xyz', subject => $topic } or die $Mail::Sender::Error; return $sender->MailMsg({ msg => $msg }) or die $Mail::Sender::Error; } } print send_mail();