jump to navigation

Step by Step Setup Postfix Mail Server on FreeBSD December 16, 2009

Posted by Devriza Wilmanura Imanta in BSD.
Tags: , , ,
2 comments

It’s Done.

1. MySQL Install
2. Dovecot Install
3. Postfix Install
4. Apache Install
5. PHP Install
6. Postfixadmin Install
7. SpamAssasin Install
8. ClamAV Install
9. PEAR Install
10. Squirrelmail Install

Any question?

Just leave your comment here.

Thank’s

FreeBSD Mail Server – 10 – Squirrelmail Install April 16, 2009

Posted by Devriza Wilmanura Imanta in BSD.
Tags: , , , ,
add a comment

SquirrelMail is a very actively developed, fun, and easy to use webmail application. I prefer SquirrelMail mostly because of the broad list of plugins available for it. You can read more about it by visiting http://www.squirrelmail.org/.

Install SquirrelMail via ports:
#cd /usr/ports/mail/squirrelmail
#make all install clean

SquirrelMail configuration:
#cd /usr/local/www/squirrelmail
#./configure

SquirrelMail Options:
1. Choose option “2. Server Settings“.
2. Choose option “1. Domain” and change it to your domain name.
3. Choose option “A. Update IMAP Settings” then option “5. IMAP Port” and change it to “993“.
4. Choose option “7. Secure IMAP (TLS)” and change it to “true” by pressing “y“.
5. Choose option “8. Server software” then type”dovecot” followed by the “ENTER” to set it.
6. Press “s” followed by the “ENTER” key to save.
7. Press “q” followed by the “ENTER” key to quit.

Edit /usr/local/etc/apache22/Includes/squirrelmail.conf file:
Alias /squirrelmail/ "/usr/local/www/squirrelmail/"
<Directory "/usr/local/www/squirrelmail">
AllowOverride None
Options None
Order allow,deny
Allow from all
</Directory>

Reload Apache configuration:
#apachectl graceful

Test:

Squirrelmail sudah terinstall. Masuk ke “http://domain.tld/squirrelmail/src/configtest.php” untuk memastikan tidak ada error, jika masih ada error, coba untuk mengikuti petunjuk yang ada di error tersebut.

Semoga Tutorial ini Membantu
Terima kasih

Prev : PEAR Install

FreeBSD Mail Server – 9 – PEAR Install April 16, 2009

Posted by Devriza Wilmanura Imanta in BSD.
Tags: , , ,
add a comment

PEAR stands for “PHP Extension and Application Repository” which describes it perfectly. It comes in very handy when dealing with web applications. You can read more about PEAR at http://pear.php.net/.

Install PEAR via ports:
#cd /usr/ports/devel/pear
#make all install clean

Edit /usr/local/etc/php.ini file:
Find and edit the RED TEXT:
...
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2"
include_path = ".:/usr/local/share/pear"
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"

Prev : ClamAV Install – Next : Squirrelmail Install

FreeBSD Mail Server – 8 – ClamAV Install April 16, 2009

Posted by Devriza Wilmanura Imanta in BSD.
Tags: , , , ,
add a comment

Clam Anti-Virus is a free virus scanning utility that works like a charm. Thus far I haven’t had any issues with it. You can also install many other AV scanners that Maia-Mailguard can use. You are not limited to one. You can read more about ClamAV by visiting the web site at http://www.clamav.net/.

Install Clam Anti-Virus via ports:
#cd /usr/ports/security/clamav
#make all install clean CLAMAVUSER=vscan CLAMAVGROUP=vscan
(Menu defaults should be fine.)

Install Clam Anti-Virus via ports:
#cd /usr/ports/security/clamav
#make all install clean CLAMAVUSER=vscan CLAMAVGROUP=vscan
(Menu defaults should be fine.)

Add build options to /etc/make.conf file:
This will keep you from having to use those build options every time you upgrade your ClamAV port.
#echo 'CLAMAVUSER=vscan' >> /etc/make.conf
#echo 'CLAMAVGROUP=vscan' >> /etc/make.conf

Enable ClamAV at boot time:
#echo 'clamav_freshclam_enable="YES"' >> /etc/rc.conf
#echo 'clamav_clamd_enable="YES"' >> /etc/rc.conf

Start FreshClam as well as the ClamAV daemon:
#/usr/local/etc/rc.d/clamav-clamd start
#/usr/local/etc/rc.d/clamav-freshclam start

Prev : SpamAssasin Install – Next : Pear Install

FreeBSD Mail Server – 7 – SpamAssasin Install April 16, 2009

Posted by Devriza Wilmanura Imanta in BSD.
Tags: , , ,
add a comment

SpamAssassin is a great tool for detecting spam. Although it may be a bit ‘bloated’ and resource hungry, I still like to use it. Whether or not you want to use it is up to you. I’ve heard of others trading this step out for spamd but I haven’t gotten around to integrating it properly. So, SpamAssassin it is! You can read more about SpamAssassin by visiting their web site at http://spamassassin.apache.org/.

Install SpamAssassin via ports:
#cd /usr/ports/mail/p5-Mail-SpamAssassin
#make all install clean
(Be sure “SPAMC” is NOT selected and “GNUPG“, “MYSQL“, and “RAZOR” are selected in the menu)

Create user “vscan”:
#pw groupadd vscan
#pw useradd -n vscan -c Amavisd\ User -d /var/amavisd -g vscan -m
#passwd vscan
(Enter password twice)

Create and edit /usr/local/etc/mail/spamassassin/local.cf file:
use_bayes 1
bayes_store_module Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn DBI:mysql:maia
bayes_sql_username vscan
bayes_sql_password vscan_password
auto_whitelist_factory Mail::SpamAssassin::SQLBasedAddrList
user_awl_dsn DBI:mysql:maia
user_awl_sql_username vscan
user_awl_sql_password vscan_password
bayes_auto_expire 0
# Change 192.168.1.* to your actual internal/external address(es).
internal_networks 192.168.1.0/24
trusted_networks 192.168.1/24

Configure RAZOR for reporting:
#su - vscan
#razor-admin -discover
#razor-admin -create
#razor-admin -register -l -user=username@domain.tld -pass=some_password
#exit

Prev : Postfixadmin Install – Next : ClamAV Install

FreeBSD Mail Server – 6 – Postfixadmin Install April 16, 2009

Posted by Devriza Wilmanura Imanta in BSD.
Tags: , , , ,
add a comment

PostfixAdmin is a great application to edit your e-mail domains and users. It has plenty of options and makes things very easy. You can check it out by visiting their website at http://sourceforge.net/projects/postfixadmin/.

Install Postfixadmin via ports:
#cd /usr/ports/mail/postfixadmin
#make all install clean
(Be sure “MYSQLI” is selected in the menu.)

Create PostfixAdmin database:
Execute adjusting the RED TEXT.
#mysql -u root -p
(Enter MySQL root password)
>CREATE DATABASE postfix;
>CREATE USER 'postfix'@'localhost' IDENTIFIED BY 'postfix_sql_password';
>GRANT ALL PRIVILEGES ON `postfix` . * TO 'postfix'@'localhost';
>FLUSH PRIVILEGES;
>exit

Secure PostfixAdmin files:
#cd /usr/local/www/postfixadmin
#find . -type f -exec chmod 640 {} \;
#find . -type d -exec chmod 750 {} \;

Edit /usr/local/www/postfixadmin/config.inc.php file:
Find and edit the RED TEXT.

$CONF['configured'] = true;
$CONF['postfix_admin_url'] = 'https://www.domain.tld/postfixadmin/';
$CONF['database_type'] = 'mysqli';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'postfix';
$CONF['database_password'] = 'postfix_sql_password';
$CONF['database_name'] = 'postfix';
$CONF['database_prefix'] = '';
$CONF['admin_email'] = 'postmaster@domain.tld';
$CONF['default_aliases'] = array (
'abuse' => 'abuse@domain.tld',
'hostmaster' => 'hostmaster@domain.tld',
'postmaster' => 'postmaster@domain.tld',
'webmaster' => 'webmaster@domain.tld'
);
$CONF['generate_password'] = 'NO';
$CONF['page_size'] = '20';
$CONF['domain_path'] = 'YES';
$CONF['domain_in_mailbox'] = 'NO';
$CONF['aliases'] = '50';
$CONF['mailboxes'] = '50';
$CONF['maxquota'] = '1024';
$CONF['quota'] = 'YES';
$CONF['quota_multiplier'] = '1048576';
$CONF['transport'] = 'NO';
$CONF['vacation'] = 'YES';
$CONF['vacation_domain'] = 'autoreply.domain.tld';
$CONF['alias_control_admin'] = 'YES';
$CONF['special_alias_control'] = 'YES';
$CONF['show_header_text'] = 'YES';
$CONF['header_text'] = ':: Postfix Admin ::';
$CONF['show_footer_text'] = 'YES';
$CONF['footer_text'] = 'Return to domain.tld';
$CONF['user_footer_link'] = 'http://www.domain.tld/';
$CONF['welcome_text'] = <<<EOM
Hello,

Welcome to your new email account!

For questions or comments regarding your mail account,
please feel free to send an email to support@domain.tld.
Likewise, any other inqueries regarding ISP NAME or their
affiliates can be sent to the same address.

Also, don't forget to check your mail settings via Maia-
Mailguard located at https://www.domain.tld/maia-mailguard/.
Simply log into your account using your email address
and password. That's it! From Maia-Mailguard, you can
adjust your spam, virus, malware, whitelists, blacklists,
etc... This will put you in full control of your email so
you never miss anything important.

Thank you for using ISP NAME and enjoy your new email
account!

Regards,
ISP NAME Staff
support@domain.tld
EOM;
?>
$CONF['emailcheck_resolve_domain']='NO';

Create Vacation user and group accounts:
#pw groupadd vacation
#pw useradd vacation -c Virtual\ Vacation -d /nonexistent -g vacation -s /sbin/nologin

Create, populate and secure vacation directory:
#mkdir /var/spool/vacation
#cp /usr/local/www/postfixadmin/VIRTUAL_VACATION/vacation.pl /var/spool/vacation/
#chown -R vacation:vacation /var/spool/vacation/
#chmod 700 /var/spool/vacation/
#chmod 750 /var/spool/vacation/vacation.pl
#touch /var/log/vacation.log /var/log/vacation-debug.log
#chown vacation:vacation /var/log/vacation*>

Edit /var/spool/vacation/vacation.pl script:
Find and edit the RED TEXT.
my $db_type = 'mysql';
my $db_host = 'localhost';
my $db_user = 'postfix';
my $db_pass = 'postfix_sql_password';
my $db_name = 'postfix';
my $sendmail = "/usr/sbin/sendmail";
my $logfile = "/var/log/vacation.log"; # specify a file name here for example: vacation.log
my $debugfile = "/var/log/vacation-debug.log"; # sepcify a file name here for example: vacation.debug
my $syslog = 1; # 1 if log entries should be sent to syslog
...

Edit /usr/local/etc/postfix/master.cf for vacation filter:
Add this to the bottom of the file.
vacation unix - n n - - pipe
flags=DRhu user=vacation argv=/var/spool/vacation/vacation.pl

Edit /usr/local/etc/postfix/main.cf for vacation transport:
Find and edit the RED TEXT.
... # TRANSPORT MAP
#
# See the discussion in the ADDRESS_REWRITING_README document.
transport_maps = hash:/usr/local/etc/postfix/transport
vacation_destination_recipient_limit = 1

...

Add proper lines to /usr/local/etc/postfix/transport file:
#echo 'autoreply.domain.tld vacation:' >> /usr/local/etc/postfix/transport

Create our transport map database for Postfix:
#postmap /usr/local/etc/postfix/transport

Create and edit /usr/local/etc/apache22/Includes/postfixadmin.conf file:

Alias /postfixadmin/ "/usr/local/www/postfixadmin/"
    <Directory "/usr/local/www/postfixadmin/">
       Options Indexes
       AllowOverride AuthConfig
       Order allow,deny
       Allow from all
    </Directory>


Reload Apache configuration:

#apachectl configtest
#apachectl gracefu
l

Run all startup scripts:
#/usr/local/etc/rc.d/mysql-server start (Should already be running?)
#/usr/local/etc/rc.d/dovecot start
#/usr/local/etc/rc.d/postfix start

Note:

Check /var/log/maillog dan /var/log/messages untuk memastikan tidak ada error.

Test and setup PFA admin:

Masuk ke “http://domain.tld/postfixadmin/. Click “setup”, jika tidak ada problem, Anda disuruh untuk memasukkan email dan password yang akan digunakan sebagai admin pada postfixadmin ini. Jika semua berjalan sukses, delete file /usr/local/www/postfixadmin/setup.php atau pindahkan ke directory lain atau rename.

Add a domain and user to Postfix:

Masuk “http://domain.tld/postfixadmin/”, masukkan email dan password admin postfixadmin yang sudah Anda lakukan pada langkah di atas. Klik “Domain List”, kemudian “New Domain” dan isi domain seperti yang diminta. Selanjutnya klik “Virtual List”, klik “Add Mailbox” dan isi field-field yang di sediakan.

Telnet to localhost on port 25:
#telnet localhost 25
Trying 127.0.0.1…
Connected to localhost.domain.tld.
Escape character is ‘^]’.
220 test.domain.tld ESMTP Postfix
EHLO test.com
250-test.domain.tld
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH LOGIN PLAIN
250-AUTH=LOGIN PLAIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
STARTTLS
220 2.0.0 Ready to start TLS
quit
quit

Jika pada waktu telnet ke port 25 ada error :
postfix/smtpd[771]: fatal: proxymap service is not configured for table “unix:passwd.byname” , coba jalanin perintah berikut:
postconf -e ‘proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps

Telnet to localhost on port 465:
#telnet localhost 465
Trying 127.0.0.1…
Connected to host.domain.tld.
Escape character is ‘^]’.
quit
quit

Note:

Anda tidak melihat apa-apa pada tes diatas, karena sekarang Anda memerlukan SSL. Coba menggunakan Mail Client untuk mencoba SSL SMTP ini

.

Telnet to localhost on port 110:
#telnet localhost 110
Connected to host.domain.tld.
Escape character is ‘^]’.
+OK ISP Mail Server Ready.
user user@domain.tld (Use the account you created via the web interface)
+OK
pass password (Use password you just created for above user)
+OK Logged in.
list
+OK 1 messages:
1 844
.
quit
+OK Logging out
Connection closed by foreign host.

Check /var/log/maillog, jika tidak ada error, Anda sudah berhasil membuat Virtual Domain/User pada Postfix.

Prev : PHP Install – Next : SpamAssasin Install

FreeBSD Mail Server – 5 – PHP Install April 16, 2009

Posted by Devriza Wilmanura Imanta in BSD.
Tags: , , ,
add a comment

PHP is a very powerful language used mostly for web applications. Hence the reason we are installing it. Each application that is accessible via the web in this tutorial depends on PHP to work properly. You can check out more on PHP by visiting their web site at http://www.php.net/.

Install PHP via ports:
#cd /usr/ports/lang/php5
#make all install clean (Be sure “APACHE” is selected in the menu)

Install PHP extentions:
#cd /usr/ports/lang/php5-extensions
#make all install clean
(Be sure “BCMATH“, “GETTEXT“, “IMAP“, “MCRYPT“, “MYSQL“, “MYSQLI“, “SESSION“, “SOCKETS“, and “WDDX” are selected in the menu)

Prepare /usr/local/etc/php.ini file:
#cp /usr/local/etc/php.ini-recommended /usr/local/etc/php.ini

Edit /usr/local/etc/php.ini file:
Find and edit the RED TEXT.
...
;;;;;;;;;;;;;;;;;;;;;;;;;
; Paths and Directories ;
;;;;;;;;;;;;;;;;;;;;;;;;;
; UNIX: "/path1:/path2"
include_path = "."
;
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
...

Edit /usr/local/etc/apache22/httpd.conf file:
Find and edit the RED TEXT.
...
DirectoryIndex index.html index.php index.php5

...
...
TypesConfig etc/apache22/mime.types
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Restart Apache:
#apachectl restart

Prev : Apache Install – Next : Postfixadmin Install