GioielloTestMail

Indice

Situazione iniziale

Server dns con installato sendmail Client dns con installato mailutils (e Postfix)

root@ns:/var/mail# netstat -tap

Connessioni Internet attive (server e stabiliti)
Proto CodaRic CodaInv Indirizzo locale        Indirizzo remoto       Stato       PID/Program name
tcp        0      0 localhost:953           *:*                     LISTEN      1576/named      
tcp        0      0 localhost:smtp          *:*                     LISTEN      974/sendmail: MTA: 
tcp        0      0 localhost:submission    *:*                     LISTEN      974/sendmail: MTA:

Il client tenta di mandare al server mail con

# echo -e "Subject:Titolo\nCiao" | sendmail -v tech@gioiellons.tes.mi.it

Ottenendo il seguente log

root@GioielloNSClient:/# tail -f /var/log/mail.log

Dec 11 09:32:32 GioielloNSClient postfix/smtp[2571]: connect to gioiellons.tes.mi.it[10.200.7.20]:25: Connection refused
Dec 11 09:32:32 GioielloNSClient postfix/smtp[2571]: D6ECC4415E: to=<tech@gioiellons.tes.mi.it>, relay=none, delay=0.02, delays=0.01/0.01/0/0, dsn=4.4.1, status=deferred (connect to gioiellons.tes.mi.it[10.200.7.20]:25: Connection refused)

Obiettivo

Agire sul server affinchè RICEVA la posta entrante

Azioni svolte

Partendo dall'errore Connection refused, implementiamo quanto suggerito su

http://www.cyberciti.biz/tips/sendmail-is-only-accepting-connections-from.html
  • Editare /etc/mail/sendmail.mc
#11-12-2015 Gioiello modifica per accettare posta entrante. Segue linea originale
#DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp, Addr=127.0.0.1')dnl

#11-12-2015 Gioiello segue riga modificata
DAEMON_OPTIONS(`Family=inet,  Name=MTA-v4, Port=smtp')dnl
  • Compilare la configurazione con
# m4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
  • Riavviare il servizio
# service sendmail restart

Esito

root@ns:/var/mail# netstat -tap

Connessioni Internet attive (server e stabiliti)
Proto CodaRic CodaInv Indirizzo locale        Indirizzo remoto       Stato       PID/Program name
tcp        0      0 localhost:smtp          *:*                     LISTEN      1721/sendmail-mta


Nel file originale appare

O DaemonPortOptions=Family=inet,  Name=MTA-v4, Port=smtp, Addr=127.0.0.1
O DaemonPortOptions=Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1

Invece dopo la modifica appare

O DaemonPortOptions=Family=inet,  Name=MTA-v4, Port=smtp, Addr=127.0.0.1
O DaemonPortOptions=Family=inet,  Name=MTA-v4, Port=smtp
O DaemonPortOptions=Family=inet,  Name=MSP-v4, Port=submission, M=Ea, Addr=127.0.0.1


Con questa configurazione NON parte perchè la riga 2 entra in conflitto con la riga 1 che NON viene cancellata.
Soluzione trovata:

Commentando la riga 2, si ripristina lo stato originale.
Invece commentando la riga 1 si apre la porta.

Risultato:

root@ns:/etc/mail# netstat -tap

Connessioni Internet attive (server e stabiliti)
Proto CodaRic CodaInv Indirizzo locale        Indirizzo remoto       Stato       PID/Program name
tcp        0      0 *:smtp                  *:*                     LISTEN      1393/sendmail: MTA:
tcp        0      0 localhost:953           *:*                     LISTEN      896/named       
tcp        0      0 localhost:submission    *:*                     LISTEN      1393/sendmail: MTA:

E la posta arriva

root@ns:/etc/mail# tail -f /var/log/mail.log

Dec 11 09:51:26 ns sm-mta[979]: daemon MTA-v4: problem creating SMTP socket
Dec 11 09:51:31 ns sm-mta[979]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA-v4: cannot bind: Address already in use
Dec 11 09:51:31 ns sm-mta[979]: daemon MTA-v4: problem creating SMTP socket
Dec 11 09:51:36 ns sm-mta[979]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA-v4: cannot bind: Address already in use
Dec 11 09:51:36 ns sm-mta[979]: daemon MTA-v4: problem creating SMTP socket
Dec 11 09:51:41 ns sm-mta[979]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA-v4: cannot bind: Address already in use
Dec 11 09:51:41 ns sm-mta[979]: daemon MTA-v4: problem creating SMTP socket
Dec 11 09:51:41 ns sm-mta[979]: NOQUEUE: SYSERR(root): opendaemonsocket: daemon MTA-v4: server SMTP socket wedged: exiting
Dec 11 10:02:15 ns sm-mta[1314]: starting daemon (8.14.4): SMTP+queueing@00:10:00
Dec 11 10:03:52 ns sm-mta[1393]: starting daemon (8.14.4): SMTP+queueing@00:10:00
Dec 11 10:04:28 ns sm-mta[1409]: tBB94RjO001409: from=<root@GioielloNSClient.gioiellons.tes.mi.it>, size=329, class=0, nrcpts=1, msgid=<20151211090428.8673F44174@GioielloNSClient.gioiellons.tes.mi.it>, proto=ESMTP, daemon=MTA-v4, relay=GioielloNSClient.gioiellons.tes.mi.it [10.200.7.40]
Dec 11 10:04:28 ns sm-mta[1410]: tBB94RjO001409: to=<tech@gioiellons.tes.mi.it>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=30604, dsn=2.0.0, stat=Sent