JAVA SCRIPT

RH 253: HOW TO CONFIGURE SENDMAIL

1>> TO CONFIGURE SMTP

1. vim /var/named/forward.zone  (Dns should resolve mail server)
   server          IN MX 5         server.example.com.

2. service named restart


3. host -t MX server.example.com

4. yum install sendmail-cf -y


5. vim /etc/mail/sendmail.mc
    line 115 ->comment
    line 155 -> put your domain name


6. make -C /etc/mail


7. service sendmail restart

Verify -> netstat -tlpn |grep :25  (uses loopback after configuration uses ip)


2>> TO SEND  MAILS

A> Using telnet
->  telnet server.matrix.com  25
  -> mail from:u1@server.matrix.com
  -> rcpt to: u2@server.matrix.com
  -> data
  -> subject: hello
  -> aaaaaaaaaaaaaaaaaaaaaaaaaa
     aaaaaaaaaaaaaaaaaaaaaaaaaa 

 (then press enter and . to send)
     quit

B> Using MAIL command
->  mail u1@server.matrix.com
    aaaaaaaaaaaaaaaaaaaaaaaaaa  

  (again . to send mail)

C> Using MUTT command
-> mutt  u1@server.example.com


3>> TO CHECK MAILS

1. su - <user>
   mail

2. mail -u <user>

3. tailf /var/spool/mail/<user>




LOCAL HOST NAMES



just put your domain name here

1. server.matrix.com
2. service sendmail restart



ALIASES


1>>  TO SET ALIASES TO USER,

Mail sent to a virtual group to be received by all users of virtual group


1. vim /etc/aliases
   admin:   u1,u2

2. newaliases

3. mail admin@server.matrix.com

4. mail -u u1
5. mail -u u2           

->both would have received same mail




    

 VIRTUSER TABLE

Mail sent to u1 should be redirected to u2.


1.  vim /etc/mail/virtusertable
    u1@virtual.matrix.com        u1@server.matrix.com

2.  vim /etc/mail.local-host-names
     server.matrix.com
     virtual.matrix.com

3. make -C /etc/mail


4. service sendmail restart


5. mail u1@virtual.matrix.com


6. mail  -u    admin                ->Receives mail

Any mail sent user of host virtual.matrix.com is received by admin user of server.matrix.com



ACCESS


TO RESTRICT OR ALLOW ACCESS TO CERTAIN USERS/DOMAIN

1a. To  Reject mails FROM this IP
   ->vim /etc/mail/access
   192.168.0.45            REJECT        ->This IP cant send/receive mails

b. make -C  /etc/mail
c. service  sendmail restart
d. -> telnet  server.matrix.com  25           (Try this frm 192.168.0.45 machine)
   mail from:u2@server.matrix.com             ->Not Allowed


2a. To  Reject mails FROM this Domain
     ->vim /etc/mail/access
     192.168.0               REJECT        ->Any ips frm this domain cant access

2b.  make -C  /etc/mail
2c.  service sendmail restart
2d.  telnet  server.matrix.com  25          
     mail from:u2@server.matrix.com         ->Not Allowed


3a. To  Reject mails TO u1
   ->vim /etc/mail/access
   TO:u1@server.matrix.com     REJECT        ->u1 cant receive mail

3b.  make -C  /etc/mail
3c.  service sendmail restart
3d.  telnet  server.matrix.com  25          
     mail from:u2@server.matrix.com   ->ok
     rcpt to  :u1@server.matrix.com   ->FAIL


4. To  Reject mails FROM u1
-> vim /etc/mail/access
   FROM:u1@server.matrix.com   REJECT        ->u1 cant send mail

4b.  make -C  /etc/mail
4c.  service sendmail restart
4d.  telnet  server.matrix.com  25          
     mail from:u1@server.matrix.com   ->FAIL
  

5. To  Reject mails FROM u1 with a ERROR
-> vim /etc/mail/access
   FROM:u1@server.matrix.com   ERROR:STUPID  ->display error message

5b.  make -C  /etc/mail
5c.  service sendmail restart
5d.  telnet  server.matrix.com  25          
     mail from:u1@server.matrix.com   -> Get error message
   



GENERICS TABLE

 TO MASQUERADE THE FROM ADDRESS OF MAIL

1. vim /etc/mail/sendmail.mc   

 (Add below lines to sendmail.mc file)
   MASQUERADE_AS(`suma.virtual.com')dnl     ->edit hostname
   FEATURE(masquerade_envelope)dnl          ->uncomment
   FEATURE(masquerade_entire_domain)dnl     - uncomment
   MASQUERADE_DOMAIN(suma.virtual.com)dnl    ->edit hostname
   FEATURE(genericstable)dnl                 ->write below 3 lines   
   FEATURE(always_add_domain)dnl
   GENERICS_DOMAIN_FILE(/etc/mail/local-host-names)dnl


2. vim /etc/mail/local-host-names
    server.example.com
    suma.virtual.com

3.  vim /etc/mail/genericstable
    @server.matrix.com             admin@suma.virtual.com

4. make -C /etc/mail

5. service sendmail restart

6.  mail  u1@server.matrix.com

7. mail -u u1        ->mail appears to come from admin@suma.virtual.com   thou mail was actually sent from root@server.matrix.com   



DOVECOT

TO CONFIGURE DOVECOT

1.yum install dovecot  -y
2.vim /etc/dovecot.conf
   uncomment line 17
3.service dovecot restart


TO CHECK MAIL USING POP3

1. telnet server.matrix.com  110
   user  <username>                ->Type user and provide username
   pass  <password>                ->Type pass and provide password
   list                            ->List the mails
   retr 1                          ->Read the mail
   quit

2. mutt -f pop3://u1@server.matrix.com


TO Check mail using IMAPS AND POP3S (Secured)

1. cd /etc/pki/tls/certs
2. make dovecot.pem
3. cp dovecot.pem  /etc/pki/tls/certs/private
4. cp dovecot.pem  /etc/pki/tls/dovecot/private
5. vim /etc/dovecot.conf
   uncomment line 87,88
6. service dovecot restart

2> mutt  -f imaps://u1@server.matrix.com
 













If you found this post useful, I would really love it, if you can Like the Page, or share it with your Facebook/Google+/Twitter Friends... It will keep me motivated. Thank you!

No comments:

Post a Comment