0

I'm running a cloud VM (18.04), and I'm trying to get emails from unattended-upgrades. Can someone tell me the easiest way to get these emails forwarded to me? I've tried several guides for postfix and sendmail, and none of them have managed to send a test email. This all seems overly difficult for forwarding simple system notifications.

Does anyone have a simple solution for this?

1 Answers1

0

Not sure, if that would help you, but i have used a perl script to check if some condition is true and then send out e-mail.

    #!/usr/bin/perl

    $mailfrom = "root\@myomain.com";
    $mailto = "root\@mydomain.com";

    use FileHandle;

    ##### Check some condition
    if (some condition to be true) {
        push @New,$_;
    }

    ##### Send mail if true
    if (@New) {
        my $data = qx("e-mail body here");
        $mail = new FileHandle;
        $mail->open("| /usr/sbin/sendmail -t") || die "Cannot open: $!";
        $mail->print("From: $mailfrom\n");
        $mail->print("To: $mailto\n");
        $mail->print("Subject: some subject\n\n");
        $mail->print(@New, "\n");
        $mail->print($data, "\n");
        $mail->close();
    }
Taavi
  • 686