Ok, I probably should wait until tomorrow, but I am very tired of trying and failing at this tonight, so am seeking your wisdom, please.

I am building a newsletter for a client of mine, that will be built into his site, I am making it where they can subscribe(and unsubscribe) via clicking a link in an email, OR hitting reply to the message.

I am piping the email to a script, but keep getting this error:
pipe to |/home/user/main_files/email.pl generated by registration@domain.com local delivery failed


Here is the main portion of the script, that is getting the information...
use CGI qw(:standard); use Mail::Address; use MIME::Parser; use MIME::Entity; use MIME::Body; use Data::Dumper; use Mail::Sendmail; use Email::DB; # All these changed for demo purposes only $dbh = Email::DB::connect(); $_req_dir = '/home/user/main_files'; # Changed, for demo purposes. require "$_req_dir/vars.conf"; get_site_values(); # loaded from vars.conf above. %vars = Get_Page_Vars(\%vars,"subscribe_page_vars"); # Also loaded + from vars.conf print header(-type=>"plain/text"); # I have NO Idea why I did this + :o), tried it with and without, still same error :o( $parser = new MIME::Parser; $parser->ignore_errors(1); $parser->output_to_core(1); my $MIME_entity = $parser->parse(\*STDIN); my $error = ($@ || $parser->last_error); $header = $MIME_entity->head; $subject = $header->get('Subject'); $from = $header->get('From'); $cto = $header->get('To'); @to_addresses = Mail::Address->parse($cto); @from_addresses = Mail::Address->parse($from); my $address; if (@to_addresses) { $to = $to_addresses[0]->address(); } else { exit; } if (@from_addresses) { $from = $from_addresses[0]->address(); } else { exit; } if ($MIME_entity->parts > 0) { for (my $i=0;$i<$MIME_entity->parts;$i++) { my $subEntity = $MIME_entity->parts($i); my $ignore_plain = 0; my $ignore_html = 0; $ishtml = "1" if $subEntity->mime_type eq 'text/html'; $ishtml = "0" if $subEntity->mime_type eq 'text/plain'; if (($subEntity->mime_type eq 'text/html') && ($ignore_htm +l == 0)) { if (my $io = $subEntity->open("r")) { while (defined($_=$io->getline)) { $_ =~ s/"/\"/g; $body .= $_; } $io->close; $ignore_plain=1; } } if (($subEntity->mime_type eq 'text/plain') && ($ignore_pl +ain=0)) { if (my $io = $subEntity->open("r")) { while (defined($_=$io->getline)) { $_ =~ s/"/\"/g; $body .= $_; } $io->close; $ignore_html=1; } } } } else { $body = join "", @{$MIME_entity->body}; } $to = $1 if $to =~ /<(\S+)>/; if ($from =~ /<(\S+)>/) { $newfrom = $1 } else { $newfrom = $fr +om } $body =~ s/"/\"/g; if (($subject =~ /^(remove|unsubscribe)/i) || ($to =~ /(remove|rem +oval|unsubscribe)/i)) { UnSubscribe_User($from); } elsif ($subject =~ /\|/) { Subject_Parser($subject); } else { die "Could not run script! $!"; exit; }


Is there an easier way to do this, that you know of? I am so frustrated with this :o(

Thank you for any advise you can offer me.

Have a good night.
thx,
Richard

In reply to email parsing by powerhouse

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.