Howto: receive mail and save attachment with fetchmail, procmail and metamail
You will need
In this example I'll use a POP3 account, the full mail will be backed up to ~/mail_backup, and attachments will be unpacked to ~/attachments. fetchmail also handles IMAP accounts just fine. Please refer to the fetchmail documentation.
Setting up fetchmail
First create a file $HOME/.fetchmailrc
poll my.pop3.server
protocol pop3
user 'myuser'
password 'mypassword'
mda '/usr/bin/procmail -d %T'
Setting up procmail and metamail
Then we configure procmail so it forwards the messages to metamail in $HOME/.procmailrc
:0
*^content-Type:
{
# backup the complete mail first..
# you can leave out this part if you don't want a backup of the complete mail
:0c:
$HOME/mail_backup
# Now the actual unpacking part
#
# this is the place where the attachments will be unpacked to
METAMAIL_TMPDIR=$HOME/attachments
# forward to metamail
:0fw
| metamail -w -y -x
}
Regarding metamail, we tell it to ignore any mailcap file, so it doesn't use interpreters (-w), yanking the message and save the content raw (-y) and force it in non-interactive mode (-x).
That's it about it. We are ready for testing.
Test run
Now we simply fire up fetchmail, the rest should be magic.
fetchmail -kv
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Fortinet FortiWeb Web Application Firewall Policy BypassFrom: Geffrey Velasquez Date: Wed, 2 May 2012 20:33:23 -0500...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.