Fetchmail: Difference between revisions

From Request Tracker Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
==  
==Using fetchmail to poll POP-boxes for incoming email for RT==
Using fetchmail to poll POP-boxes for incoming email for RT ==






Sometimes you don't have enough control over the email system to pipe incoming email directly into a program as it arrives - for instance when you're not the email admin. Using the fetchmail program in daemon mode or called by the cron you can periodically check one or more POP-boxes for incoming email and send them into RT.
Sometimes you don't have enough control over the email system to pipe incoming email directly into a program as it arrives - for instance when you're not the email admin. Using the fetchmail program in daemon mode or called by the cron you can periodically check one or more POP-boxes for incoming email and send them into RT.






First you require a fetchmailrc-file which tells fetchmail all the pop-boxes, for instance in /usr/rt/etc/fetchmailrc
First you require a fetchmailrc-file which tells fetchmail all the pop-boxes, for instance in /usr/rt/etc/fetchmailrc




  poll pop.example.com    proto pop3:
  poll pop.example.com    proto pop3:
  username rt            password mypw1  mda "/usr/rt/bin/rt-mailgate --url http://rt.example.com[http://www.profi-fachuebersetzung.de .] --queue General --action correspond"
  username rt            password mypw1  mda "/usr/rt/bin/rt-mailgate --url http://rt.example.com[http://www.profi-fachuebersetzung.de .] --queue General --action correspond"
Line 22: Line 20:




If you use a queue with a blank like 'bug report', you must set the queue name in ' '.
If you use a queue with a blank like 'bug report', you must set the queue name in ' '.






Then you simply need to call fetchmail:
Then you simply need to call fetchmail:




  fetchmail -f /usr/rt/etc/fetchmailrc
  fetchmail -f /usr/rt/etc/fetchmailrc






This can be done on any machine that can reach both the POP-server by POP and the RT-Server by HTTP. I prefer to do it directly on the RT-Server.
This can be done on any machine that can reach both the POP-server by POP and the RT-Server by HTTP. I prefer to do it directly on the RT-Server.






--- Back to the [[Documentation]] page
--- Back to the [[Documentation]] page




== Using getmail to poll POP-boxes for incoming email for RT==
==Using getmail to poll POP-boxes for incoming email for RT==




getmail (http://pyropus.ca/software/getmail/) is similar to fetchmail, but provides a few more features. The most useful one is the abillity to delete email from the inbox you are polling after a set time period. It requires a little extra configuration.
getmail (http://pyropus.ca/software/getmail/) is similar to fetchmail, but provides a few more features. The most useful one is the abillity to delete email from the inbox you are polling after a set time period. It requires a little extra configuration.






First, install and build getmail from http://pyropus.ca/software/getmail/.
First, install and build getmail from http://pyropus.ca/software/getmail/.






You will need a configuration file for each email you intend to check (so this means two configs for each queue- one for replies and one for comments). An example config is below.
You will need a configuration file for each email you intend to check (so this means two configs for each queue- one for replies and one for comments). An example config is below.




  [retriever]
  [retriever]
  type = SimplePOP3Retriever
  type = SimplePOP3Retriever
Line 77: Line 73:




Notes:
Notes:




*
*
In destination, user and group must be a user and group on the server that getmail runs on. Getmail will fail to run if you try to run it as root without explicitly allowing it to. As this is a security risk, it recommended you create a user/group for getmail to use. The RT user and group seems to work perfectly.
In destination, user and group must be a user and group on the server that getmail runs on. Getmail will fail to run if you try to run it as root without explicitly allowing it to. As this is a security risk, it recommended you create a user/group for getmail to use. The RT user and group seems to work perfectly.


*
*
In destination, an entry must be made for each argument that is separate by a space. If there is only one argument, don't forget the trailing comma.
In destination, an entry must be made for each argument that is separate by a space. If there is only one argument, don't forget the trailing comma.


*
*
delete_after tells getmail to delete the email 8 days after seeing it for the first time on the server.
delete_after tells getmail to delete the email 8 days after seeing it for the first time on the server.


*
*
read_all prevents it from reading every mail on the server each time it connects.
read_all prevents it from reading every mail on the server each time it connects.






Create a config for each of your emails (in this example, let us say we have a .examplereplyrc and a .examplecommentrc). After creating these, you should create a shell script as below to run as a cron job.
Create a config for each of your emails (in this example, let us say we have a .examplereplyrc and a .examplecommentrc). After creating these, you should create a shell script as below to run as a cron job.




  #!/bin/bash
  #!/bin/bash
  /usr/bin/getmail --rcfile /path/to/.examplereplyrc --rcfile /path/to/.examplecommentrc
  /usr/bin/getmail --rcfile /path/to/.examplereplyrc --rcfile /path/to/.examplecommentrc
Line 103: Line 98:




Add this shell script to your crontab to complete your setup.
Add this shell script to your crontab to complete your setup.

Revision as of 11:13, 2 February 2012

Using fetchmail to poll POP-boxes for incoming email for RT

Sometimes you don't have enough control over the email system to pipe incoming email directly into a program as it arrives - for instance when you're not the email admin. Using the fetchmail program in daemon mode or called by the cron you can periodically check one or more POP-boxes for incoming email and send them into RT.


First you require a fetchmailrc-file which tells fetchmail all the pop-boxes, for instance in /usr/rt/etc/fetchmailrc


poll pop.example.com    proto pop3:
username rt             password mypw1   mda "/usr/rt/bin/rt-mailgate --url http://rt.example.com. --queue General --action correspond"
username rt-comment     password mypw2   mda "/usr/rt/bin/rt-mailgate --url http://rt.example.com --queue General --action comment"
username queue1         password mypw3   mda "/usr/rt/bin/rt-mailgate --url http://rt.example.com --queue queue1  --action correspond"
username queue1-comment password mypw4   mda "/usr/rt/bin/rt-mailgate --url http://rt.example.com --queue queue1  --action comment"
username queue2         password mypw5   mda "/usr/rt/bin/rt-mailgate --url http://rt.example.com --queue queue2  --action correspond"
username queue2-comment password mypw6   mda "/usr/rt/bin/rt-mailgate --url http://rt.example.com --queue queue2  --action comment"


If you use a queue with a blank like 'bug report', you must set the queue name in ' '.


Then you simply need to call fetchmail:


fetchmail -f /usr/rt/etc/fetchmailrc


This can be done on any machine that can reach both the POP-server by POP and the RT-Server by HTTP. I prefer to do it directly on the RT-Server.


--- Back to the Documentation page


Using getmail to poll POP-boxes for incoming email for RT

getmail (http://pyropus.ca/software/getmail/) is similar to fetchmail, but provides a few more features. The most useful one is the abillity to delete email from the inbox you are polling after a set time period. It requires a little extra configuration.


First, install and build getmail from http://pyropus.ca/software/getmail/.


You will need a configuration file for each email you intend to check (so this means two configs for each queue- one for replies and one for comments). An example config is below.


[retriever]
type = SimplePOP3Retriever
server = mail.example.com
port = 110
username = test@example.com
password = password

[destination]
type = MDA_external
path = /path/to/rt-mailgate
user = rtuser
group = rtgroup
arguments = ("--url", "http://rt.example.com", "--queue", "ExampleQueue", "--action", "correspond",)

[options]
read_all = false
delete_after = 8
verbose = 2


Notes:


In destination, user and group must be a user and group on the server that getmail runs on. Getmail will fail to run if you try to run it as root without explicitly allowing it to. As this is a security risk, it recommended you create a user/group for getmail to use. The RT user and group seems to work perfectly.

In destination, an entry must be made for each argument that is separate by a space. If there is only one argument, don't forget the trailing comma.

delete_after tells getmail to delete the email 8 days after seeing it for the first time on the server.

read_all prevents it from reading every mail on the server each time it connects.


Create a config for each of your emails (in this example, let us say we have a .examplereplyrc and a .examplecommentrc). After creating these, you should create a shell script as below to run as a cron job.


#!/bin/bash
/usr/bin/getmail --rcfile /path/to/.examplereplyrc --rcfile /path/to/.examplecommentrc


Add this shell script to your crontab to complete your setup.