<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How To Send an Email With Attachment and Body from Linux</title>
	<atom:link href="http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/</link>
	<description>Guides, HowTos and Tips for Technology Geeks</description>
	<lastBuildDate>Thu, 09 Feb 2012 13:04:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Network-Engineer</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-88999</link>
		<dc:creator>Network-Engineer</dc:creator>
		<pubDate>Thu, 24 Feb 2011 12:26:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-88999</guid>
		<description>Hi

First congrats on your daughter&#039;s birth. Be happy and be safe. I have a question related to postfix. I want to monitor one single email user of my domain. e.g. i want to monitor ne@xyz.com how many emails it has sent out, how many sent successfully, how many rejected and how many deffered. now i have a script with me that works fine for me and give me output like how many total ne@xyz..com sent out, how many rejected and how many deffered. i&#039;m goin to share this script with you here. what i want to add to this script is that it should give me the email addresses that are rejected. you know what i mean. it current tells me 750 emails are sent by this user. 200 rejected 100 deffered etc i want to know what email addresses are rejected. so if 200 are rejected it should give me 200 emails address aswell so i can see if there is spell mistake or something. here is the script. please have a look at this. or if you know any other software to monitor this kindly let me know. i want to moniter my postfix user who is sending out newsletters. i want reports how many are sent how many rejected how many deffered etc. which rejected emails.

here is script that i am using but it&#039;s not givin me emails rejected. just the counts.

#!/usr/bin/perl
# vim:ts=2:sw=2:expandtab:cindent

### MAKE MODIFICATIONS FOR DATE AND SENDING EMAIL ADDRESS HERE ###

#$date=&quot;Oct  14[5-9]&quot;;
$date=&quot;Dec 18&quot;;
#$sender=&quot;(.*)\@domain.com&quot;; # Matches any sender from domain.com
#$sender=&quot;username\@domain.com&quot;; # Matches abc@domain.com
$sender=&quot;user\@domain.com&quot;; # Matches user@domain.com

###                    END OF USER MODIFICATIONS               ###

$sent = 0;
$bounced = 0;
$deferred = 0;

$logFile=&quot;/var/log/maillog&quot;;
open LOGFILE, &quot;&lt;&quot;, $logFile;
@rawLogs = ;
close LOGFILE;

$date =~ s/^([A-Z][a-z]{2})( )([0-9])$/$1  $3/; 
printf(&quot;%s %s\n&quot;,$sender, $date);

if ( grep(/(^[A-Z][a-z]{2}  [0-9])$/, $date) ) {
  $field = 6;
} else {
  $field = 5;
}
    
@logs = grep(/$date .* postfix\/qmgr\[[0-9]+\]: .* from=/i, @rawLogs);
foreach (@logs) {
  @line = split(/ /);
  push(@msgIds, $line[$field]);
}

@sent = grep (/status=sent/, @rawLogs);
@bounced = grep (/status=bounced/, @rawLogs);

@ids = grep {defined} map {
  if (exists $u{$_}) { 
    undef; 
  } else {
    $u{$_}=undef; $_; 
  }
} @msgIds;

undef %u;

$i=0;
$cnt = $#ids + 1;
foreach $id(@ids) {
  $final=0;
  if (grep(/$id/, @sent)) {
    $sent++;
    $final=1;
  } elsif (grep(/$id/, @bounced)) {
    $bounced++;
    $final=1;
  }
  if ($final != 1) {
    $deferred++;
  }
  $i++;  
}
print &quot;Messages Delivered: $sent\n&quot;;
print &quot;Messages Bounced: $bounced\n&quot;;
print &quot;Messages Deferred: $deferred\n&quot;;
print &quot;Total Sent: &quot;. ( $sent + $bounced + $deferred ) .&quot;\n&quot;;</description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>First congrats on your daughter&#8217;s birth. Be happy and be safe. I have a question related to postfix. I want to monitor one single email user of my domain. e.g. i want to monitor <a href="mailto:ne@xyz.com">ne@xyz.com</a> how many emails it has sent out, how many sent successfully, how many rejected and how many deffered. now i have a script with me that works fine for me and give me output like how many total ne@xyz..com sent out, how many rejected and how many deffered. i&#8217;m goin to share this script with you here. what i want to add to this script is that it should give me the email addresses that are rejected. you know what i mean. it current tells me 750 emails are sent by this user. 200 rejected 100 deffered etc i want to know what email addresses are rejected. so if 200 are rejected it should give me 200 emails address aswell so i can see if there is spell mistake or something. here is the script. please have a look at this. or if you know any other software to monitor this kindly let me know. i want to moniter my postfix user who is sending out newsletters. i want reports how many are sent how many rejected how many deffered etc. which rejected emails.</p>
<p>here is script that i am using but it&#8217;s not givin me emails rejected. just the counts.</p>
<p>#!/usr/bin/perl<br />
# vim:ts=2:sw=2:expandtab:cindent</p>
<p>### MAKE MODIFICATIONS FOR DATE AND SENDING EMAIL ADDRESS HERE ###</p>
<p>#$date=&#8221;Oct  14[5-9]&#8220;;<br />
$date=&#8221;Dec 18&#8243;;<br />
#$sender=&#8221;(.*)\@domain.com&#8221;; # Matches any sender from domain.com<br />
#$sender=&#8221;username\@domain.com&#8221;; # Matches <a href="mailto:abc@domain.com">abc@domain.com</a><br />
$sender=&#8221;user\@domain.com&#8221;; # Matches <a href="mailto:user@domain.com">user@domain.com</a></p>
<p>###                    END OF USER MODIFICATIONS               ###</p>
<p>$sent = 0;<br />
$bounced = 0;<br />
$deferred = 0;</p>
<p>$logFile=&#8221;/var/log/maillog&#8221;;<br />
open LOGFILE, &#8220;&lt;&quot;, $logFile;<br />
@rawLogs = ;<br />
close LOGFILE;</p>
<p>$date =~ s/^([A-Z][a-z]{2})( )([0-9])$/$1  $3/;<br />
printf(&#8220;%s %s\n&#8221;,$sender, $date);</p>
<p>if ( grep(/(^[A-Z][a-z]{2}  [0-9])$/, $date) ) {<br />
  $field = 6;<br />
} else {<br />
  $field = 5;<br />
}</p>
<p>@logs = grep(/$date .* postfix\/qmgr\[[0-9]+\]: .* from=/i, @rawLogs);<br />
foreach (@logs) {<br />
  @line = split(/ /);<br />
  push(@msgIds, $line[$field]);<br />
}</p>
<p>@sent = grep (/status=sent/, @rawLogs);<br />
@bounced = grep (/status=bounced/, @rawLogs);</p>
<p>@ids = grep {defined} map {<br />
  if (exists $u{$_}) {<br />
    undef;<br />
  } else {<br />
    $u{$_}=undef; $_;<br />
  }<br />
} @msgIds;</p>
<p>undef %u;</p>
<p>$i=0;<br />
$cnt = $#ids + 1;<br />
foreach $id(@ids) {<br />
  $final=0;<br />
  if (grep(/$id/, @sent)) {<br />
    $sent++;<br />
    $final=1;<br />
  } elsif (grep(/$id/, @bounced)) {<br />
    $bounced++;<br />
    $final=1;<br />
  }<br />
  if ($final != 1) {<br />
    $deferred++;<br />
  }<br />
  $i++;<br />
}<br />
print &#8220;Messages Delivered: $sent\n&#8221;;<br />
print &#8220;Messages Bounced: $bounced\n&#8221;;<br />
print &#8220;Messages Deferred: $deferred\n&#8221;;<br />
print &#8220;Total Sent: &#8220;. ( $sent + $bounced + $deferred ) .&#8221;\n&#8221;;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-65509</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Thu, 07 Oct 2010 15:07:20 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-65509</guid>
		<description>Thanks a bunch. That last part about emailing both an attachment and a body file was exactly what I needed. We&#039;re moving from AIX to Linux and I needed to find a replacement for metasend. We have a lot of programs that use metasend. Instead of changing 60 programs, I now have a 60 line script to parse out the info from the metasend command and pass it to uuencode and mail. Fantastic.

Thanks Again,

Martin</description>
		<content:encoded><![CDATA[<p>Thanks a bunch. That last part about emailing both an attachment and a body file was exactly what I needed. We&#8217;re moving from AIX to Linux and I needed to find a replacement for metasend. We have a lot of programs that use metasend. Instead of changing 60 programs, I now have a 60 line script to parse out the info from the metasend command and pass it to uuencode and mail. Fantastic.</p>
<p>Thanks Again,</p>
<p>Martin</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Carl</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-30895</link>
		<dc:creator>Carl</dc:creator>
		<pubDate>Mon, 25 Jan 2010 17:29:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-30895</guid>
		<description>How about

cat mail.txt &#124; mutt -a attachment -s subject me@to.com</description>
		<content:encoded><![CDATA[<p>How about</p>
<p>cat mail.txt | mutt -a attachment -s subject <a href="mailto:me@to.com">me@to.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: hideaki</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-29558</link>
		<dc:creator>hideaki</dc:creator>
		<pubDate>Fri, 15 Jan 2010 09:57:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-29558</guid>
		<description>cat-uuencode-and-a-pie is pretty lame. There ought to be some tool that does a proper MIME packing of the mail.</description>
		<content:encoded><![CDATA[<p>cat-uuencode-and-a-pie is pretty lame. There ought to be some tool that does a proper MIME packing of the mail.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Silviu Marin-Caea</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-28413</link>
		<dc:creator>Silviu Marin-Caea</dc:creator>
		<pubDate>Tue, 05 Jan 2010 08:58:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-28413</guid>
		<description>On opensuse 11.2 do this:
echo text body &#124; mail -s &quot;Subject line&quot; -a attachment.txt person@internet.com</description>
		<content:encoded><![CDATA[<p>On opensuse 11.2 do this:<br />
echo text body | mail -s &#8220;Subject line&#8221; -a attachment.txt <a href="mailto:person@internet.com">person@internet.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felipealvarez</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-28257</link>
		<dc:creator>felipealvarez</dc:creator>
		<pubDate>Mon, 04 Jan 2010 04:47:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-28257</guid>
		<description>mail -s subject email@domain &lt; filetosend
base64 filetosend &#124; mail -s subject email@domain

The above two do not &#039;attach&#039; the file to message. Instead, they are in the BODY of the message. Why is this?

Using opensuse 11.2 (postfix)</description>
		<content:encoded><![CDATA[<p>mail -s subject email@domain &lt; filetosend<br />
base64 filetosend | mail -s subject email@domain</p>
<p>The above two do not &#039;attach&#039; the file to message. Instead, they are in the BODY of the message. Why is this?</p>
<p>Using opensuse 11.2 (postfix)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Frank Daley</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-27854</link>
		<dc:creator>Frank Daley</dc:creator>
		<pubDate>Wed, 30 Dec 2009 21:25:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-27854</guid>
		<description>I think that mutt is a lot simpler. For example, it can be installed on Fedora

yum -y install mutt

To use it is simply

mutt -s &quot;Subject text&quot; emailaddress &lt; filetosend.odt</description>
		<content:encoded><![CDATA[<p>I think that mutt is a lot simpler. For example, it can be installed on Fedora</p>
<p>yum -y install mutt</p>
<p>To use it is simply</p>
<p>mutt -s &#8220;Subject text&#8221; emailaddress &lt; filetosend.odt</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-27828</link>
		<dc:creator>John</dc:creator>
		<pubDate>Wed, 30 Dec 2009 16:46:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-27828</guid>
		<description>I have for a long time used a little app called &quot;email&quot; from http://www.cleancode.org/projects/email .. It compiles easily and has served me really well. It will use your favourite console editor to write the body text, attach files very easily, cat text from a file for body text, use a sig line if wanted and I believe it even has a simple addressbook and some other tricks, like multiple attachments very simply.

I almost only use it from scripts though, backing up configs and stuff to a file dump email address</description>
		<content:encoded><![CDATA[<p>I have for a long time used a little app called &#8220;email&#8221; from <a href="http://www.cleancode.org/projects/email" rel="nofollow">http://www.cleancode.org/projects/email</a> .. It compiles easily and has served me really well. It will use your favourite console editor to write the body text, attach files very easily, cat text from a file for body text, use a sig line if wanted and I believe it even has a simple addressbook and some other tricks, like multiple attachments very simply.</p>
<p>I almost only use it from scripts though, backing up configs and stuff to a file dump email address</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed Deloye</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-27807</link>
		<dc:creator>Ed Deloye</dc:creator>
		<pubDate>Wed, 30 Dec 2009 13:46:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-27807</guid>
		<description>You can do the same thing with mutt:

mutt -s &#039;subject&#039; -i file1 -a file2 -c user1@domain -b user2@domain user3@doman &lt;/dev/null

-s Specify the subject of the message.
-i   Specify a file to include into the body of a message.
-a  Attach a file to your message using MIME.
-c Specify a carbon-copy (CC) recipient
-b Specify a blind-carbon-copy (BCC) recipient

The redirect from /dev/null prevents mutt from going into interactive mode</description>
		<content:encoded><![CDATA[<p>You can do the same thing with mutt:</p>
<p>mutt -s &#8216;subject&#8217; -i file1 -a file2 -c user1@domain -b user2@domain user3@doman &lt;/dev/null</p>
<p>-s Specify the subject of the message.<br />
-i   Specify a file to include into the body of a message.<br />
-a  Attach a file to your message using MIME.<br />
-c Specify a carbon-copy (CC) recipient<br />
-b Specify a blind-carbon-copy (BCC) recipient</p>
<p>The redirect from /dev/null prevents mutt from going into interactive mode</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mahesh</title>
		<link>http://www.thegeekstuff.com/2009/12/how-to-send-an-email-with-attachment-and-body-from-linux/comment-page-1/#comment-27801</link>
		<dc:creator>Mahesh</dc:creator>
		<pubDate>Wed, 30 Dec 2009 13:21:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.thegeekstuff.com/?p=3080#comment-27801</guid>
		<description>I have found mutt to be a lot useful for sending attachment.</description>
		<content:encoded><![CDATA[<p>I have found mutt to be a lot useful for sending attachment.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Content Delivery Network via Amazon Web Services: CloudFront: static.thegeekstuff.com

Served from: www.thegeekstuff.com @ 2012-02-09 13:44:55 -->
