EzDevInfo.com

mailman

An incoming mail processing microframework in Ruby

Receiving old emails with POP3 using Mailman

I'm very new to mailman, just trying to create a handler so I can get notification when I receive new mail , something like that :

require "rubygems"
require "mailman"

Mailman.config.pop3 = {
  server: 'pop.gmail.com', port: 995, ssl: true,
  username: "email@gmail.com",
  password: "password"
}

Mailman::Application.run do
  default do
    puts message.subject
  end
end

Anyways for somereasone I keep getting long list of old emails subjects instead of the new one, I'm totally sure i'm doing something wrong here, but how can I make it just receive the new coming mails ?


Source: (StackOverflow)

How to submit the form to two different pages

I'm creating a register form for a mail list. After submit the form, I'd like to register all data in the database and then "re-submit" the data to another page to register the user on the mail list.

I know how to register all data in the database, however I don't know how to "re-submit" the data to another page.

Why it's necessary? It's necessary, because I'm using the GNU Mailman as mail list system. This software only store name, e-mail and password, then I can't create a register form with custom fields, like "Country", "City" and "Gender".


Source: (StackOverflow)

Advertisements

How messages are organized into thread? [closed]

guys. Can anyone explain how mailing messages are organized into threads? As I understood, messages are sent always to the same email of the group. So there has to be some identifier of thread...


Source: (StackOverflow)

python command in php system()

I'm trying to write php code to change the description name of mailman's mailing list automatically using the php's system() function. But I don't know how can I do.

<?php
system('bin/withlist -l market
m.description = 'NewName'
m.Save()
exit()');
?>

Here is the command line commands to change the description name:

$ bin/withlist -l market
>>> m.description = 'NewName'
>>> m.Save()
>>> exit()

Please help me


Source: (StackOverflow)

Files in docker container disappear

I am working on creating a backup script for some Docker contains. Some really strange thing happens when I copy files from a dir inside a Docker container to a host mounted dir - The files disappear.

EDIT: I managed to simplify the example and isolate the strange phenomenon:

#!/usr/bin/env bash

docker run -it --name  gen_skeleton_cont \
        mailman_server \
        ls /etc && \
        echo "Second ls:" && \
        ls /etc \    

# Cleanup the gen_skeleton_cont:
docker rm -f gen_skeleton_cont

The output of running this script is:

$ sudo bash check_incon.sh 
Muttrc        bash.bashrc             cron.monthly    environment  hosts.allow      issue.net      logcheck        mke2fs.conf    os-release  python     rc6.d         services  sudoers      ufw
Muttrc.d      bash_completion.d       cron.weekly     fstab        hosts.deny       kbd            login.defs      modprobe.d     pam.conf    python2.7  rcS.d         sgml      sudoers.d    update-motd.d
X11           bindresvport.blacklist  crontab         fstab.d      init             kernel         logrotate.conf  modules        pam.d       python3    resolv.conf   shadow    supervisor   upstart-xsessions
adduser.conf  blkid.conf              dbus-1          gai.conf     init.d           ld.so.cache    logrotate.d     mtab           passwd      python3.4  resolvconf    shadow-   sysctl.conf  vim
aliases       blkid.tab               debconf.conf    group        initramfs-tools  ld.so.conf     lsb-release     network        passwd-     rc.local   rmt           shells    sysctl.d     vtrgb
aliases.db    ca-certificates         debian_version  group-       inputrc          ld.so.conf.d   magic           networks       perl        rc0.d      rpc           skel      syslog-ng    wgetrc
alternatives  ca-certificates.conf    default         gshadow      insserv          ldap           magic.mime      newt           postfix     rc1.d      rsyslog.conf  ssl       systemd      xml
apache2       console-setup           deluser.conf    gshadow-     insserv.conf     legal          mailcap         nologin        ppp         rc2.d      rsyslog.d     subgid    terminfo
apparmor      cron.d                  depmod.d        host.conf    insserv.conf.d   libaudit.conf  mailcap.order   nsswitch.conf  profile     rc3.d      securetty     subgid-   timezone
apparmor.d    cron.daily              dhcp            hostname     iproute2         locale.alias   mailman         ntp.conf       profile.d   rc4.d      security      subuid    ucf.conf
apt           cron.hourly             dpkg            hosts        issue            localtime      mime.types      opt            protocols   rc5.d      selinux       subuid-   udev
Second ls:
acpi                    ca-certificates.conf  dhcp          host.conf        kbd              lsb-release     opt                      python3.4        screenrc   sudoers            w3m
adduser.conf            calendar              digitalocean  hostname         kernel           ltrace.conf     os-release               rc0.d            securetty  sudoers.d          wgetrc
alternatives            chatscripts           dpkg          hosts            kernel-img.conf  magic           pam.conf                 rc1.d            security   sysctl.conf        wireshark
apm                     cloud                 environment   hosts.allow      landscape        magic.mime      pam.d                    rc2.d            selinux    sysctl.d           wpa_supplicant
apparmor                console-setup         fish          hosts.deny       ldap             mailcap         passwd                   rc3.d            services   systemd            X11
apparmor.d              cron.d                fonts         ifplugd          ld.so.cache      mailcap.order   passwd-                  rc4.d            sgml       terminfo           xml
apport                  cron.daily            fstab         init             ld.so.conf       manpath.config  perl                     rc5.d            shadow     timezone           zsh_command_not_found
apt                     cron.hourly           fstab.d       init.d           ld.so.conf.d     mime.types      pm                       rc6.d            shadow-    ucf.conf
at.deny                 cron.monthly          fuse.conf     initramfs-tools  legal            mke2fs.conf     polkit-1                 rc.digitalocean  shells     udev
bash.bashrc             crontab               gai.conf      inputrc          libaudit.conf    modprobe.d      popularity-contest.conf  rc.local         skel       ufw
bash_completion         cron.weekly           groff         insserv          libnl-3          modules         ppp                      rcS.d            smi.conf   updatedb.conf
bash_completion.d       dbus-1                group         insserv.conf     locale.alias     mtab            profile                  resolvconf       ssh        update-manager
bindresvport.blacklist  debconf.conf          group-        insserv.conf.d   localtime        nanorc          profile.d                resolv.conf      ssl        update-motd.d
blkid.conf              debian_version        grub.d        iproute2         logcheck         network         protocols                rmt              subgid     update-notifier
blkid.tab               default               gshadow       iscsi            login.defs       networks        python                   rpc              subgid-    upstart-xsessions
byobu                   deluser.conf          gshadow-      issue            logrotate.conf   newt            python2.7                rsyslog.conf     subuid     vim
ca-certificates         depmod.d              hdparm.conf   issue.net        logrotate.d      nsswitch.conf   python3                  rsyslog.d        subuid-    vtrgb
gen_skeleton_cont

As can be seen, the two invocations of ls give different results. Maybe the container hasn't finished loading? I must be missing something.

If it helps, the full repository is here (Including Docker files): https://github.com/realcr/mailman_docker


Source: (StackOverflow)

Unable to check checkbox via Perl LWP::UserAgent

How should I check a checkbox like this:

<td><center><INPUT name="test2%40mydomain.com_notmetoo" type="CHECKBOX" value="off" ></center></td>

with Perl's LWP::UserAgent module?

This code doesn't do it (the output is as if it was submitted without the checkbox being checked - i.e. the webpage gets refreshed and the checkbox cleared).

#!/usr/bin/perl
use LWP::UserAgent;

$ua = new LWP::UserAgent;
$ua->cookie_jar({ file => "$ENV{HOME}/.mailmanrc" });

$res = $ua->post('http://mydomain.com/mailman/admin/test1_mydomain.com/members/list',
    Content_Type => 'form-data',
    Content => [
        'test2%40mydomain.com_notmetoo' => 'on',
        setmemberopts_btn => 'Submit Your Changes'
    ]
);
if ($res->is_success) {
    print $res->decoded_content;
    print "Changed user setting...I hope!\n";
}
else {
    die $res->status_line;
}

I'm not sure why the "@" is represented by "%40" in the element name (any ideas?), but I've also tried: 'test2\%40mydomain.com_notmetoo' => 'on', and 'test2@mydomain.com_notmetoo' => 'on', without success.

There seems to be no JavaScript on the website (i.e. it works fine in my browser with JavaScript disabled). I just can't get it to work in Perl.

Thanks.

Terry.


Update #1: Here's the POSTDATA value from Firefox's 'Tamper Data' extension when I submit after checking Test2's notmetoo box:

POSTDATA =-----------------------------2921376274802
Content-Disposition: form-data; name="findmember"


-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_realname"

Test1
-----------------------------2921376274802
Content-Disposition: form-data; name="user"

test1%40mydomain.com
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_hide"

on
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_notmetoo"

on
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_plain"

on
-----------------------------2921376274802
Content-Disposition: form-data; name="test1%40mydomain.com_language"

en
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_realname"

Test2
-----------------------------2921376274802
Content-Disposition: form-data; name="user"

test2%40mydomain.com
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_hide"

on
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_notmetoo"

off
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_plain"

on
-----------------------------2921376274802
Content-Disposition: form-data; name="test2%40mydomain.com_language"

en
-----------------------------2921376274802
Content-Disposition: form-data; name="test3%40mydomain.com_realname"

Test3
-----------------------------2921376274802
Content-Disposition: form-data; name="user"

test3%40mydomain.com
-----------------------------2921376274802
Content-Disposition: form-data; name="test3%40mydomain.com_hide"

on
-----------------------------2921376274802
Content-Disposition: form-data; name="test3%40mydomain.com_plain"

on
-----------------------------2921376274802
Content-Disposition: form-data; name="test3%40mydomain.com_language"

en
-----------------------------2921376274802
Content-Disposition: form-data; name="setmemberopts_btn"

Submit Your Changes
-----------------------------2921376274802
Content-Disposition: form-data; name="allmodbit_val"

0
-----------------------------2921376274802--

Does that help anyone to help me?


Source: (StackOverflow)

Simple/lightweight alternative to GNU Mailman?

I'm looking for a dead simple mailing list (unix friendly). Robustness, fine-grained configurability, "enterprise-readiness" (whatever that means) are not requirements. I just need to set up a tiny mailing list for a few friends. Rather than hack something up myself, I was wondering if anybody knows of anything already out there with a similar goal?

I should note right now that I don't want an externally hosted mailing list -- it needs to be software I can install and run on my server. I know of many places I can host a mailing list at (Google/Yahoo groups), but it would be nice to keep the data local.


Source: (StackOverflow)

Is there a good way to migrate from a Mailman list to an web forum?

I have a Mailman managed list with years of history that I want to migrate into a web-based forum. Things it would be nice to do:

  • Keep the mailing list going for those who are used to and prefer it to a web interface, but have it integrate with the web-forum activity.

  • Take the web-based forum posts, and send them out to the mailing list.

I have run sites based on phpBB, Drupal, Simple Machines, etc., and am able to do a little bit of coding if that was what was required to integrate some package into Mailman, or replace it entirely. But I'm unaware of what is available, commercial, or open-source, that could accomplish this. I am also open to replacing Mailman, if the candidate package can perform its functions reasonably well and integrate well into its own forum.


Source: (StackOverflow)

Looking for a PHP mailing list App (not for newsletters)

I am not sure if I'm calling this correctly by the right name, what I would like to find (if it exists) is a group mailing list app (like mailman) but in php.

Here is what I expect it to do:

Allow for users to email mailinglist@domain.com with subject like TEAM123 - Deadline is 11/30/2011 (or maybe just team123@domain.com) and this application would CHECK the mailbox

It would check the mailbox, and forward that message to all users in TEAM123. So the email thread would then be created.

Users then would be notified in TEAM123, and by replying, would update the mail thread (the emails would then again go out to everyone). Maybe at this point the app would update a running conversation on the site (store it in DB? etc).

I think I'm calling the process properly 'mailing list service' etc..

Anyone aware of anything like this in PHP? I would use this for a sports league, players would just have to update via email and the whole team would be updated.

Thanks! Appreciate any ideas on this...


Source: (StackOverflow)

Ruby: How to demonize MailMan (incoming mail processing microframework)

I'm using mailman gem for fetching email from pop3 server and send it to Rails application. What should I do to make mailman be as daemon? Please, tell me easiest way to do it.

May be whenever gem can help? Something like:

  every :reboot do

    command "cd /home/rails/root && ruby bin/mailman_fetcher.rb"

  end

Source: (StackOverflow)

Does Mailman have an API or an export lists, users and owners option?

I am trying to migrate a legacy mailing list to a new web forum software and was wondering if mailman has an export option or an API to get all lists, owners, members and membership types.


Source: (StackOverflow)

MailMan and Saving Attachments

I'm using the mailmain gem to grab pop3 mail. This library uses the mail gem to break up the message body and attachments. I'm to the point where I can get the attachment in the pry command line like so:

14: Mailman.config.rails_root = '../'
15: 
16: Mailman::Application.run do
17:   to 'expenses@surveymonkey.com' do
18:     require 'debugger'; debugger
=> 19:     print message
20:   end
21: end

and I can get an individual attachment like so

[1] pry(#<Mailman::Router>)> a = message.attachments[0]
=> #<Mail::Part:70339703566060, Multipart: false, Headers: <Content-Type: image/jpeg;   name="70s-Jump-Suit.jpeg">, <Content-Transfer-Encoding: base64>, <Content-Disposition: attachment; filename="70s-Jump-Suit.jpeg"; size=38412; creation-date="Tue, 26 Jun 2012 22:11:10 GMT"; modification-date="Tue, 26 Jun 2012 22:11:10 GMT">, <Content-Description: 70s-Jump-Suit.jpeg>>

So, the question is, how do I save this data?

I'm close with this method, but I'm unable to properly save.

and I've tried stuff like this

[2] pry(#<Mailman::Router>)> File.open( '/tmp/output.jpg', "w+b", 0644 ) { |f| f.write a.raw_source }

but the output gets botched.

I just don't know enough about email encoding to get this to work.

Thanks in advance!


Source: (StackOverflow)

Turn a ruby script into an always running job

I have created a program that I need to run constantly. It currently lives at scripts/mailman. I start it by doing this:

sudo bundle exec rails runner script/mailman &

It seams to stop after I logout of the server. Here is the contents of my mailman program:

#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "mailman"
require "rb-inotify"

Mailman.config.logger = Logger.new("/var/log/mailman.log")
Mailman.config.maildir = '/var/mail'
require File.dirname(__FILE__) + "/../../config/application"
Rails.application.require_environment!
Mailman::Application.run do
   default do
       begin
           Bin.receive_mail(message)
       end
   end
end

What is a good way to start this program automatically and keep it running always? I am running this on Ubuntu.


Source: (StackOverflow)

Postfix-Mailman "Recipient address rejected: User unknown in local recipient table"

I assume the error is an issue with my postfix configuration. I've followed the steps in the instructions here to set up apache/postfix/mailman.

Real domain replaced with mydomain.com I've created a default mail list called mailman. When I send an email to mailman@mydomain.com I get the error "Recipient address rejected: User unknown in local recipient table" in the mail.log.

550 5.1.1 <mailman@mydomain.com>: Recipient address rejected: User unknown in local recipient table; from=<-----@gmail.com> to=<mailman@mydomain.com> proto=ESMTP helo=<mail-wi0-f174.google.com>

Excerpts from my postfix/main.cf:

myhostname = mydomain.com
mydestination = mydomain.com, localhost
inet_protocols = ipv4
relay_domains = mydomain.com
transport_maps = hash:/etc/postfix/transport
mailman_destination_recipient_limit = 1

Excerpts from /etc/postfix/transport

mydomain.com mailman:

Excerpt from postfix/master.cf

mailman   unix  -       n       n       -       -       pipe
  flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
  ${nexthop} ${user}

If I understand correctly how it should work...

  1. mail comes in to mydomain.com
  2. postfix validates the hostname against $myhostname
  3. postfix finds mydomain.com under relay_domains
  4. postfix relays the mail to the transport listed under transport_maps
  5. failing here? the postmap table finds that mailman@mydomain.com matches mydomain.com
  6. postmap directs the mail to the mailman: transport defined in master.cf
  7. the transport mailman: calls postfix-to-mailman.py, and mailman handles the mail

Source: (StackOverflow)

Ruby (Rails) email (base64) gets split at diacritics and content lost in mysql

I have a problem with my app that reads e-mails from external server using mailman gem (which is also using mail).

ruby 1.9.2p0
mail (2.3.0)
mailman (0.4.0) 
actionmailer (= 3.1.3)

database.yml

production:
  adapter: mysql2
  encoding: utf8

Here is a simple method to receive 'mail'. I build @message_body from text_part of multipart email (for ex. with attachments) or from the whole body (decoded).

def self.receive_mail(message)
    # some code here 
    @message_body = message.multipart? ? message.text_part.body.to_s : message.body.decoded
    # some code here, to save message in database

My problem is that if the message doesn't have attachments but have diacritics, like ą ś ł ń ż ź ó ... body is split just before first diacricit. So if body is: "test żłóbek test" I will get only "test " in @message_body.

My question is how to save such a message in an elegant way, so that text part is saved in database with all diacritics.

EDIT: to make it cleaner, I get e-mails that look like this one (it's just a part of e-mail sent from gmail)

--20cf307ac4372d830104c11c8cc6 Date: Mon, 28 May 2012 20:06:16 +0200 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-2 Content-Transfer-Encoding: base64 Content-ID: <4fc3be989b76e_794650c25f6625e3@vk1057.some_domain>

dGVzdCC/s7zm8bbzsSB0ZXN0Cg==

So we have this 'body' : dGVzdCC/s7zm8bbzsSB0ZXN0Cg==

After decoding we get : 'test \xbf\xb3\xbc\xe6\xf1\xb6\xf3\xb1 test\n'

And the problem is that starting from '\xbf' data is not saved in database.

UPDATE

another example, I think this is the problem here:

irb(main):008:0* require 'base64'
=> true
irb(main):009:0> a = "test źćłżąńś"
=> "test źćłżąńś"
irb(main):010:0> b = Base64.encode64(a)
=> "dGVzdCDFusSHxYLFvMSFxYTFmw==\n"
irb(main):011:0> Base64.decode64(b)
=> "test \xC5\xBA\xC4\x87\xC5\x82\xC5\xBC\xC4\x85\xC5\x84\xC5\x9B"

see, after decode64 my diacritics are LOST, what to do to get them back?


Source: (StackOverflow)