Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-05-30 04:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found