Hi all,
So my big challenge at the moment is sending out emails under certain circumstances as may have been seen from another thread. there seems to be a lack in definitive information on how to send email out from certain hosting packages. The hope is that this thread becomes a definitive resource with working code.
At the moment I am trying this will the "sendmail" command called from within a perl script (no extra modules are needed for this). the code below is called when I need to sent an email. So far this will send a mail message to a mailbox that is part of my domain but not an external mailbox.
Does anyone know how to modify the following to get the mail beyond my own domain?
Code:
&smtpSendmailCmd ('alongwor@mydomain', 'mailbox@mydomain', 'mailbox@gmail.com', 'Hello world', 'Hello out there');
sub smtpSendmailCmd {
my ($fromAddr, $toAddr, $ccAddr, $subject, $msg) = @_;
my $SENDMAIL_CMD = "/usr/sbin/sendmail -t";
unless(open (MAIL, "| $SENDMAIL_CMD")) {
print "error.\n";
warn "Error starting sendmail: $!";
}
else {
print MAIL "From: $fromAddr\n";
print MAIL "To: $toAddr\n";
print MAIL "CC: $ccAddr\n";
print MAIL "Subject: $subject\n\n";
print MAIL $msg;
close(MAIL) || warn "Error closing mail: $!";
}
}