You bounce an email by sending a message back to the server that sent it. There are a number of possible messages but user unknown at this domain is what you want. See Mail::Message::Construct::Bounce for a very simple interface to bounce messages in perl. Note this link fails to work properly. Go to search.cpan.org and search for 'MAIL::Bounce' and it will bring it up OK

However what you really want to do is not have a catch all email address. Typically this will be (for sendmail) set up in the virtusertable like this:

[root@www root]# cat /etc/mail/virtusertable @domain.com username ...
This directs any mail sent to domain.com to usernames mail box. All you need to do provided you have root access of course is
cd /etc/mail/ vi virtusertable Now replace the @domain.com with address@domain.com username corporate@domain.com username bitbucket@domain.com username etc@domain.com username spam@domain.com spam Finally run make to recompile the .db file

Now any mail to domain.com that does not match one of the listed addresses will bounce. Note multiple 'fake' addresses go to the one username mail box.

It is easier to let the MTA bounce messages for you. Otherwise you will have to parse you mail box using the Mail::Box and friends. Note Mail::Box is the biggest pain in the ass to install as it has *lots* of dependencies, and I do mean lots. Each of these has more. Suggest use CPAN to put it on for you.

cheers

tachyon


In reply to Re: Bouncing Email w/ Perl by tachyon
in thread RESLOVED: Bouncing Email w/ Perl by soffen

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.