Forum Moderators: coopster & phranque

Message Too Old, No Replies

Trying to write a simple mailing list

anyone use net::pop3?

         

joedonahue

11:41 am on Sep 8, 2005 (gmt 0)

10+ Year Member



The ultimate goal of this list will be so that users can subscribe through a webpage, then anyone who is subscribed can send an email which will then be forwarded around to everyone else on the list as well as post onto a blog. The bulk of this is pretty straightforward, but I have a snag.

I have been using net::pop3 to actually retrieve the email and then parse it, but I can't capture the actual body of the message. If I use:

$MsgHeader = $pop3 ->top(msg_id);

Then I get an array reference with all the header information. But when I do,

$MsgContent = $pop3 ->get(msg_id);

Then I get the entire header PLUS the body. The immediate solution to me seemed to be if I could convert the array references into strings, then I can substitute the header out of the message, but all attempts have failed. SO
1) How can I store the contents of an array reference into a single string?

2) Does anyone else have any better ideas at how to do this?

~Joe Donahue

SeanW

12:36 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



Write a handler that receives the mail rather than POPping it. Most listservs set themselves up as a local alias for the MTA.

When writing email responders, I generally use procmail though, just to avoid messing around in /etc/aliases.

Sean

joedonahue

3:38 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



This sounds intriguing. I am not a complete newbie to PERL, but have done most of my work with DBI. Unfortunately, I don't understand what you're saying. Short of spelling it out for me, can you point me in the right direction to understand what you're getting at?

SeanW

3:52 pm on Sep 8, 2005 (gmt 0)

10+ Year Member



Basically you're letting the mail system accept and store the mail, then you pull it and process it.

That first part is overhead. After the MTA accepts the email from the remote site, you hook your program in such that it sends the email to your STDIN.

For example, in sendmail you can add an alias:

mailman: "¦/var/mailman/mail/mailman post mailman"

Anything sent to "mailman@example.com" will get passed through /var/mailman/mail/mailman which processes the email.

You can also do it through procmail (mail filtering) or .forward.

Take a look at your MTA's documentation on how to send email to a program rather than a mailbox. Accepting the email in your program is pretty easy, you do a while (<STDIN>) loop to process the headers and body which are separated by a blank line.

Sean