Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6328539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:28:33+00:00 2026-05-24T17:28:33+00:00

This is what I’ve got: # Examples: # logman-parse –pipe=[/path/to/pipe] –mail=[mail address] # logman-parse

  • 0

This is what I’ve got:

# Examples:
#   logman-parse --pipe=[/path/to/pipe] --mail=[mail address]
#   logman-parse --pipe=/etc/pipes/critical --mail=root@domain.net
#   logman-parse --pipe=/home/user/pipe --mail=john.doe@gmail.com

use warnings;
use strict;
use Getopt::Long;
use Mail::Sendmail;

my $pipe;
my $mailto;

GetOptions( "pipe=s"   => \$pipe,
            "mailto=s" => \$mailto
          ) or die "Could not parse command line arguments";

# Check to see if there are no arguments left over, the email address 
# supplied is valid and the file given is in fact a pipe.
my $email_regex = qr/\b[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+/;

@ARGV == 0                or die "Too many arguments supplied";
$mailto =~ $email_regex   or die "Invalid email supplied";
-p $pipe                  or die "Pipe supplied does not exist";

# Load current contents of pipe into array @pipe_lines
open( my $pipe_handle, "<", $pipe) or die "Cannot open $pipe";
my @pipe_lines = <$pipe_handle>;

# Remove duplicate array entries by first adding them all to a hash,
# then extracting the keys into another array named @uniques
my @uniques = ();
my %seen    = ();
foreach my $line (@pipe_lines) {
    if ( $seen{$line} ) {
        $seen{$line}++;
        next;
    }
    push(@uniques, $line);
}

# Formatting each value to $date, $hostname, $facility and $message. 
# Then send the formatted text.
for my $i (0 .. $#uniques) {

    # Grab each component of the log entry
    (my $timestamp, my $rest) = unpack('A16 A*', $uniques[$i]);
    my @else = split(/ /, $rest, 3);
    my $formatted_message  = "Time: " . $timestamp . "\n";
    $formatted_message    .= "Hostname: " . $else[0] . "\n";
    $formatted_message    .= "Subject: " . $else[1] . "\n";
    $formatted_message    .= "Message: " . $else[2] . "\n";

    print $formatted_message."\n";

    # Send the message
    my %mail = ( To      => $mailto,
                 From    => 'logman@localhost.localdomain',
                 Subject => 'LOGMAN: '.$else[0],
                 Message => $formatted_message
               );

    sendmail(%mail) or die $Mail::Sendmail::error;
}

I’ve double checked all the variables and everything seems to be working fine, however, it doesn’t send the email. I don’t even get any error messages. Any ideas?

EDIT: I’m using the Mail::Sendmail module. I seem to be using it correctly, so I don’t know why it isn’t working.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:28:33+00:00Added an answer on May 24, 2026 at 5:28 pm

    The LIMITATIONS section of the Mail::Sendmail docs mentions that it connects to a SMTP server on localhost unless you modify Sendmail.pm or pass a different server name in your script (as mentioned under CONFIGURATION). You didn’t specify a server in your script, and you don’t mention customizing Sendmail.pm, so it’s probably using localhost.

    Since you’re not getting an error, it’s likely that you do have a SMTP server running on localhost. But since you’re not getting the email, it’s likely that SMTP server is misconfigured. It accepts email, but can’t deliver it.

    You should also try printing $Mail::Sendmail::log after calling sendmail. That will tell you more about what happened.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is beyond both making sense and my control. That being said here is
I have found this example on StackOverflow: var people = new List<Person> { new
I want to use a temp directory that will be unique to this build.
This question is regarding the google Maps API geocoding, I'm able to geocode an
this may be a simple question but am struggling to understand how to solve
This is really blowing my mind right now! span.verti{ -moz-transform: rotate(-90deg); /* FF3.5+ */
This code displays hello in chinese char buffer[10]=hello; AfxMessageBox((LPCTSTR)buffer); while this code displays it
This is what I have: import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import
This is a portion of my XML: <MAIN> <L> <D>string1 string2 <b>string3</b> string4</D> </L>
this is my first posted question. I have a fairly complicated OQL query which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.