GioielloSendMail

Da Wiki-itsos.
Versione del 8 gen 2016 alle 10:58 di Doce (Discussione | contributi) (Invio mail tramite FC (da server a server in locale))
(diff) ← Versione meno recente | Versione attuale (diff) | Versione più recente → (diff)

Situazione iniziale

Server

Macchina virtuale GioielloNSServer
Ubuntu 14.04 Server 
IP 10.200.7.20

Client

Macchina virtuale GioielloNSClient
Ubuntu 14.04 Server
IP 10.200.7.40

Obiettivi

  1. Inviare e-mail da utente a altro utente stesso host (server)
  2. Inviare e-mail da utente del client a tech@gioiellons
  3. Abilitare relay mail su server
  4. Ricevere e inviare e-mail da internet

Azioni svolte

Inviare e-mail da utente a altro utente stesso host (server)

Installare SendMail

apt-get install sendmail

Comando per inviare e-mail tramite SendMail

echo "Subject: Test" | sendmail -v utente@localhost 

Cartella contenente e-mail ricevute

root@GioielloNS:/var/mail# ls
root  tech

root@localhost

root@GioielloNS:/var/mail# tail -f root
	by GioielloNS (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id tAR8TbfZ002816
	for <root@GioielloNS>; Fri, 27 Nov 2015 09:29:37 +0100
Received: (from root@localhost)
	by GioielloNS (8.14.4/8.14.4/Submit) id tAR8Tbx2002815
	for root@localhost; Fri, 27 Nov 2015 09:29:37 +0100
Date: Fri, 27 Nov 2015 09:29:37 +0100
From: tech <tech@GioielloNS>
Message-Id: <201511270829.tAR8Tbx2002815@GioielloNS>
Subject: Test

È presente della posta in /var/mail/root

tech@localhost

root@GioielloNS:/var/mail# tail -f tech
	by GioielloNS (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id tAR8TPin002812
	for <tech@GioielloNS>; Fri, 27 Nov 2015 09:29:25 +0100
Received: (from root@localhost)
	by GioielloNS (8.14.4/8.14.4/Submit) id tAR8TPXw002811
 	for tech@localhost; Fri, 27 Nov 2015 09:29:25 +0100
Date: Fri, 27 Nov 2015 09:29:25 +0100
From: tech <tech@GioielloNS>
Message-Id: <201511270829.tAR8TPXw002811@GioielloNS>
Subject: Test

Inviare e-mail da utente del client a tech@dominio

Su Client installare mailutils

# apt-get install mailutils

Installazione Postfix (compresa in mailutils)

Sito Internet

Nome del sistema:

localdomain

Nel file /etc/postfix/main.cf troviamo

smtpd_relay_restrictions = permit_mynetworks   permit_sasl_authenticated defer_unauth_destination
myhostname = GioielloNSClient.gioiellons.tes.mi.it
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localdomain, localhost,    localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128,  10.200.7.0/24
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

A questo punto seguire il seguente documento

Inviare Mail da Client a Server

Invio da Client

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

Esito su Server

root@ns:/var/mail# tail -f tech
Received: (from root@localhost)
	by GioielloNSClient.gioiellons.tes.mi.it (8.14.4/8.14.4/Submit) id tBI7Ua65001191
	for tech@gioiellons.tes.mi.it; Fri, 18 Dec 2015 08:30:36 +0100
Date: Fri, 18 Dec 2015 08:30:36 +0100
From: tech <tech@GioielloNSClient.gioiellons.tes.mi.it>
Message-Id: <201512180730.tBI7Ua65001191@GioielloNSClient.gioiellons.tes.mi.it>
Subject:Titolo

Ciao

Invio mail tramite FC (da server a server in locale)

Mail:

GioielloMail-FC.png

Esito sul server

From yari.gioiello@tes.mi.it  Fri Jan  8 08:38:13 2016
Return-Path: <yari.gioiello@tes.mi.it>
Received: from bbs.tes.mi.it ([192.168.1.7])
	by ns.gioiellons.tes.mi.it (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id u087cChk001288 
	for <tech@ns.gioiellons.tes.mi.it>; Fri, 8 Jan 2016 08:38:13 +0100
Message-id: <fc.000f697600085cde000f697600085cde.85cdf@tes.mi.it>
X-FC-Thread-ID: 000f6976-00085cde
Date: Fri, 08 Jan 2016 08:39:14 +0100
Subject: Prova8Gennaio
X-Mailer: FirstClass 11.1 (build 11.155)
X-FC-SERVER-TZ: 38667268
To: tech@ns.gioiellons.tes.mi.it
From: "Yari Gioiello" <yari.gioiello@tes.mi.it>
MIME-Version: 1.0
Content-Type: multipart/alternative; boundary="--=_--00085cdf.00085cde.d2b51822"

This is a multi-part message in MIME format.

----=_--00085cdf.00085cde.d2b51822
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit   

Message from FC  

----=_--00085cdf.00085cde.d2b51822
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

[...]

Inviare mail dal Dominio Locale a un dominio Internet (gmail.com)




















Per inviare una mail seguire il seguente comando

root@GioielloMail:/var/mail# echo "Subject: test" | sendmail -v esempio@gmail.com

WARNING: local host name (GioielloMail) is not qualified; see cf/README: WHO AM I?
esempio@gmail.com... Connecting to [127.0.0.1] via relay...
220 GioielloMail ESMTP Sendmail 8.14.4/8.14.4/Debian-4.1ubuntu1; Fri, 13 Nov 2015 09:42:09 +0100; (No UCE/UBE) logging access from:
localhost(OK)-localhost [127.0.0.1]
>>> EHLO GioielloMail
250-GioielloMail Hello localhost [127.0.0.1], pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-EXPN
250-VERB
250-8BITMIME
250-SIZE
250-DSN
250-ETRN
250-AUTH DIGEST-MD5 CRAM-MD5
250-DELIVERBY
250 HELP
>>> VERB
250 2.0.0 Verbose mode
>>> MAIL From:<tech@GioielloMail> SIZE=14 AUTH=tech@GioielloMail
250 2.1.0 <tech@GioielloMail>... Sender ok
>>> RCPT To:<esempio@gmail.com>
>>> DATA
250 2.1.5 <esempio@gmail.com>... Recipient ok
354 Enter mail, end with "." on a line by itself
>>> .
050 <esempio@gmail.com>... Connecting to gmail-smtp-in.l.google.com. via esmtp...
050 220 mx.google.com ESMTP l11si24358661wjw.184 - gsmtp
050 >>> EHLO GioielloMail
050 250-mx.google.com at your service, [94.84.57.166]
050 250-SIZE 35882577
050 250-8BITMIME
050 250-STARTTLS
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> STARTTLS
050 220 2.0.0 Ready to start TLS
050 >>> EHLO GioielloMail
050 250-mx.google.com at your service, [94.84.57.166]
050 250-SIZE 35882577
050 250-8BITMIME
050 250-ENHANCEDSTATUSCODES
050 250-PIPELINING
050 250-CHUNKING
050 250 SMTPUTF8
050 >>> MAIL From:<tech@GioielloMail> SIZE=295
050 250 2.1.0 OK l11si24358661wjw.184 - gsmtp
050 >>> RCPT To:<esempio@gmail.com>
050 >>> DATA
050 250 2.1.5 OK l11si24358661wjw.184 - gsmtp
050 354 Go ahead l11si24358661wjw.184 - gsmtp
050 >>> .
050 250 2.0.0 OK 1447404132 l11si24358661wjw.184 - gsmtp
050 <esempio@gmail.com>... Sent (OK 1447404132 l11si24358661wjw.184 - gsmtp)
250 2.0.0 tAD8g9Wg003383 Message accepted for delivery
esempio@gmail.com... Sent (tAD8g9Wg003383 Message accepted for delivery)
Closing connection to [127.0.0.1]
>>> QUIT
221 2.0.0 GioielloMail closing connection


GioielloMail01.png