Server IP : 85.214.239.14 / Your IP : 3.145.89.181 Web Server : Apache/2.4.62 (Debian) System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.18 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : OFF | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /proc/2/cwd/proc/2/root/proc/2/cwd/usr/share/doc/altermime/html/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.82"> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <TITLE>Postfix-alterMIME-HOWTO : Installation and Configuration</TITLE> <LINK HREF="postfix-altermime-howto-3.html" REL=next> <LINK HREF="postfix-altermime-howto-1.html" REL=previous> <LINK HREF="postfix-altermime-howto.html#toc2" REL=contents> </HEAD> <BODY> <A HREF="postfix-altermime-howto-3.html">Next</A> <A HREF="postfix-altermime-howto-1.html">Previous</A> <A HREF="postfix-altermime-howto.html#toc2">Contents</A> <HR> <H2><A NAME="s2">2.</A> <A HREF="postfix-altermime-howto.html#toc2">Installation and Configuration</A></H2> <P>This documentation is based on the Linux distribution I used (Red Hat 9 with Postfix), and although it should work on most any Linux distribution, you may need to defiate from the exact instructions to get it working on your particular flavour of Linux.</P> <H2><A NAME="ss2.1">2.1</A> <A HREF="postfix-altermime-howto.html#toc2.1">Installing alterMIME</A> </H2> <P>alterMIME can be downloaded from <A HREF="http://www.pldaniels.com/altermime/">http://www.pldaniels.com/altermime/</A>. The version I used was 0.3.1.</P> <P>Once downloaded, you need to unpack the tarball, change into the new directory and run</P> <P> <PRE> make </PRE> </P> <P>After building the altermime executable, install it as follows</P> <P> <PRE> cp altermime /usr/bin/ chown root.root /usr/bin/altermime chmod 755 /usr/bin/altermime </PRE> </P> <H2><A NAME="ss2.2">2.2</A> <A HREF="postfix-altermime-howto.html#toc2.2">Adding a Non-Privileged User To Run alterMIME</A> </H2> <P>Unless you have already done this to run other filters in Postfix, the next step is to add a user account to the system that Potfix will use to run the alterMIME filter</P> <P> <PRE> useradd -r -c "Postfix Filters" -d /var/spool/filter filter </PRE> </P> <P>Once you have created this account you need to create the account's home directory</P> <P> <PRE> mkdir /var/spool/filter chown filter.filter /var/spool/filter chmod 750 /var/spool/filter </PRE> </P> <H2><A NAME="ss2.3">2.3</A> <A HREF="postfix-altermime-howto.html#toc2.3">Creating The Script To Run alterMIME</A> </H2> <P>You now need to create the following script, changing whatever you need to personalize it</P> <P> <PRE> /etc/postfix/disclaimer </PRE> </P> <P> <HR> <PRE> #!/bin/sh # Localize these. INSPECT_DIR=/var/spool/filter SENDMAIL=/usr/sbin/sendmail # Exit codes from <sysexits.h> EX_TEMPFAIL=75 EX_UNAVAILABLE=69 # Clean up when done or when aborting. trap "rm -f in.$$" 0 1 2 3 15 # Start processing. cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; } cat >in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; } /usr/bin/altermime --input=in.$$ \ --disclaimer=/etc/postfix/disclaimer.txt \ --disclaimer-html=/etc/postfix/disclaimer.txt \ --xheader="X-Copyrighted-Material: Please visit http://www.company.com/privacy.htm" || \ { echo Message content rejected; exit $EX_UNAVAILABLE; } $SENDMAIL -oi "$@" <in.$$ exit $? </PRE> <HR> </P> <P>Once you have created this script, set the permissions to allow it to be executed by the filter user</P> <P> <PRE> chgrp filter /etc/postfix/disclaimer chmod 750 /etc/postfix/disclaimer </PRE> </P> <H2><A NAME="ss2.4">2.4</A> <A HREF="postfix-altermime-howto.html#toc2.4">Creating The Disclaimer Files</A> </H2> <P>You need to create the disclaimer text file that was specified in the disclaimer.sh file</P> <P> <PRE> /etc/postfix/disclaimer.txt </PRE> </P> <P>The content of this file is very much dependent on your requirements, but examples can be found at <A HREF="http://www.emaildisclaimers.com">http://www.emaildisclaimers.com</A>.</P> <P>In my situation, I have used the same file for both the <CODE>--disclaimer</CODE> and <CODE>--disclaimer-html</CODE> files. I tried to use the <CODE>--htmltoo</CODE> parameter to tell alterMIME to use the same file for both, but this did not seem to work correctly.</P> <H2><A NAME="ss2.5">2.5</A> <A HREF="postfix-altermime-howto.html#toc2.5">Postfix Configuration</A> </H2> <P>Finally, you need to configure Postfix to run the filter. In my case, I only wanted outgoing messages to be modified, so I explicitly configured Postfix to listen on different network interfaces, but to only run the filter on the one.</P> <P>To achieve this, you need to modify the smtp service in <CODE></CODE>etc/postfix/master.cf/ to be as follows</P> <P> <HR> <PRE> <incoming ip>:smtp inet n - y - - smtpd <outgoing ip>:smtp inet n - y - - smtpd -o content_filter=dfilt: </PRE> <HR> </P> <P>replacing <incoming ip> and <outgoing ip> with the IP addresses of the different network interfaces. In practice, these IP addresses could be bound to the same network controller.</P> <P>Now you need to add the following new service to the same file</P> <P> <HR> <PRE> dfilt unix - n n - - pipe flags=Rq user=filter argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient} </PRE> <HR> </P> <P>NOTE: You need to ensure that local processes are still able to send mail. The simplest case way is to include a line like the one below in <CODE></CODE>etc/postfix/master.cf/ (Thank you to Ian Clancy for pointing out this omisson).</P> <P> <HR> <PRE> 127.0.0.1:smtp inet n - y - - smtpd </PRE> <HR> </P> <P>Once you have done this, restart Postfix and send through some test messages whilst watching the mail log. If everything goes through fine, without any errors, you can pat yourself on the back and go get a cup of coffee.</P> <HR> <A HREF="postfix-altermime-howto-3.html">Next</A> <A HREF="postfix-altermime-howto-1.html">Previous</A> <A HREF="postfix-altermime-howto.html#toc2">Contents</A> </BODY> </HTML>