\documentclass[10pt,landscape,a4paper]{article}
\usepackage[left=0pt,top=0pt,right=0pt,bottom=0pt]{geometry}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{ae}
\usepackage{tikz}
\usetikzlibrary{shadows,positioning,calc,fit,fadings,external}
\tikzset{external/force remake}
\tikzexternalize

\newcommand{\machine}[2][]{
  \begin{pgfonlayer}{background}
    \node (machine)[%
          fill=yellow!50, opacity=.3, rounded corners, draw, dashed,
          fit=#2,inner sep=7pt,
          label={[name=machine name]below:\phantom{x}}] {};
    \end{pgfonlayer}
    \begin{pgfonlayer}{foreground}
      \node at (machine name) {\texttt{#1}};
    \end{pgfonlayer}
}

\pgfdeclarelayer{background}
\pgfdeclarelayer{foreground}
\pgfsetlayers{background,main,foreground}

\tikzstyle{service}=[fill=blue!20,
                     text width=5em, text centered,
                     minimum height=2.5em,
                     drop shadow]
\tikzstyle{client}=[fill=green!20,
                    text width=5em, text centered,
                    minimum height=2.5em,
                     drop shadow]
\tikzstyle{what}  = [sloped,font=\footnotesize]
\tikzstyle{proto} = [sloped,font=\footnotesize\ttfamily]
\tikzstyle{port}  = [sloped,font=\tiny\ttfamily]

\tikzstyle{route}     = [line width=1.5pt,line cap=rect,draw=blue!30]
\tikzstyle{from user} = [draw=green!30]
\tikzstyle{TODO}      = [draw=red!30,text=red]

\pgfdeclarehorizontalshading{shade out}{\paperheight}{
  color(0mm)=(transparent!0);
  color(20mm)=(transparent!0);
  color(30mm)=(transparent!80);
  color(40mm)=(transparent!100);
  color(50mm)=(transparent!80);
  color(60mm)=(transparent!0);
  color(\paperwidth)=(transparent!0)
}
\pgfdeclarefading{fade in}{\pgfuseshading{shade out}}

\pgfdeclarehorizontalshading{shade in}{\paperheight}{
  color(0mm)=(transparent!100);
  color(20mm)=(transparent!100);
  color(30mm)=(transparent!20);
  color(40mm)=(transparent!0);
  color(50mm)=(transparent!20);
  color(60mm)=(transparent!100);
  color(\paperwidth)=(transparent!100)
}
\pgfdeclarefading{fade out}{\pgfuseshading{shade in}}


\thispagestyle{empty}
\begin{document}

\centering
\vspace*{\fill}
\tikzsetnextfilename{network-trimmed}
\begin{tikzpicture}[trim left=10cm, trim right=10cm]

  \begin{scope}[node distance=5pt]
    % The member's machine
    \node (IMAP-client)[client]                        {IMAP client};
    \node (SMTP-client)[client] [above=of IMAP-client] {SMTP client};
    \node (web-browser)[client] [below=of IMAP-client] {Web browser};
    \machine[\textnormal{Your machine}]{ (SMTP-client) (IMAP-client) (web-browser) }
  \end{scope}

  \begin{scope}[xshift=10cm, node distance=2cm and 2cm, on grid]
    % mistral
    \node (o) {};
    \node (LDAP-producer)   [service] [above right=of o] {LDAP server};
    \node (SMTP-server-IMAP)[service] [above left=of o]  {SMTP server};
    \node (IMAP-server)     [service] [below left=of o]  {IMAP server};
    \node (mailboxes)       [service] [below right=of o] {Mailboxes};
    \machine[mistral]{ (IMAP-server) (LDAP-producer) (mailboxes) }
  \end{scope}

  \begin{scope}[xshift=10cm, yshift=-7cm]
    % harvey
    \node (webmail)[service] {Webmail};
    \machine[harvey]{ (webmail) }
  \end{scope}

  \begin{scope}[xshift=10cm, yshift=7cm, node distance=2cm and 2cm, on grid]
    % luxemburg, elefant
    \node (o) {};
    \node (SMTP-server)  [service] [left=of o]  {SMTP server};
    \node (LDAP-consumer)[service] [right=of o] {LDAP replicate};
    \machine[luxemburg\textnormal{,} elefant]{ (SMTP-server) (LDAP-consumer) }
  \end{scope}

  \begin{scope}[xshift=20cm, node distance=1.25cm, on grid]
    % gnu
    \node (o) {};
    \node (MSA)[service] [above=of o] {MSA};
    \node (MTA)[service] [below=of o] {MTA};
    \machine[gnu]{ (MSA) (MTA) }
  \end{scope}


  \begin{pgfonlayer}{background}
    \begin{scope}
      \pgfsetfading{fade in}{\pgftransformshift{\pgfpoint{14cm}{0}}}
%      \fill (-20cm,-10cm) rectangle +(40cm,20cm);
      \draw[->, route, from user]
              (IMAP-client.east)
              .. controls +(2.5cm,0) and +(-2.5cm,0) ..
              (IMAP-server.west);

      \draw[->, route, from user]
              (web-browser.south)
              .. controls +(0,-4cm) and +(-3.5cm,0) ..
              (webmail.west);
  
      \draw[->, route, from user, TODO]
              (SMTP-client.north)
              .. controls +(0,5cm) and +(-5cm,0) ..
              ($0.5*(SMTP-server)+0.5*(LDAP-consumer)+(0,1.5cm)$)
              .. controls +(5cm,0) and +(0,5cm) ..
              (MSA.north);
    \end{scope}

    \begin{scope}
      \pgfsetfading{fade out}{\pgftransformshift{\pgfpoint{14cm}{0}}}
%      \fill (-20cm,-10cm) rectangle +(40cm,20cm);
      \draw[dashed, route, from user]
              (IMAP-client.east)
              .. controls +(2.5cm,0) and +(-2.5cm,0) ..
              (IMAP-server.west);
  
      \draw[dashed, route, from user]
              (web-browser.south)
              .. controls +(0,-4cm) and +(-3.5cm,0) ..
              (webmail.west);
    
      \draw[dashed, route, from user, TODO]
              (SMTP-client.north)
              .. controls +(0,5cm) and +(-5cm,0) ..
              ($0.5*(SMTP-server)+0.5*(LDAP-consumer)+(0,1.5cm)$)
              .. controls +(5cm,0) and +(0,5cm) ..
              (MSA.north);
    \end{scope}

    \begin{scope}
      \draw[route, from user, draw=none]
              (IMAP-client.east)
              .. controls +(2.5cm,0) and +(-2.5cm,0) ..
              (IMAP-server.west)
          node[pos=0.5,above,proto] {IMAPS}
          node[pos=0.5,below,what]  {\texttt{getmail}}
          node[pos=0.96,above,port] {993};
  
      \draw[route, from user, draw=none]
              (web-browser.south)
              .. controls +(0,-4cm) and +(-3.5cm,0) ..
              (webmail.west)
          node[pos=0.5,above,proto] {HTTPS}
          node[pos=0.98,above,port] {443};
    
      \draw[route, from user, TODO, draw=none]
              (SMTP-client.north)
              .. controls +(0,5cm) and +(-5cm,0) ..
              ($0.5*(SMTP-server)+0.5*(LDAP-consumer)+(0,1.5cm)$)
          node[pos=.5,above,proto] {ESMTPSA}
          node[pos=.5,below,what]  {\texttt{sendmail}}
              .. controls +(5cm,0) and +(0,5cm) ..
              (MSA.north)
          node[pos=0.985,above,port] {587};
    \end{scope}

    \draw[->, route]
            (IMAP-server)
            .. controls +(30:2cm) and +(-120:2cm) ..
            (LDAP-producer)
        node[pos=0.5,above,proto] {LDAP}
        node[pos=0.5,below,what]  {auth. bind}
        node[pos=0.92,above,port] {389};

    \draw[->, route]
            (webmail.north)
            .. controls +(0,1.5cm) and +(0,-1.5cm) ..
            (IMAP-server.south)
        node[pos=0.5,above,proto] {IMAPS}
        node[pos=0.94,above,port] {993};

    \draw[->, route]
            (webmail.30)
            .. controls +(30:8cm) and +(0,-2.5cm) ..
            (LDAP-producer.south)
        node[pos=0.5,above,proto] {LDAP \textnormal{(over \texttt{SSH})}}
        node[pos=0.15,align=center,what] {bind to \\ mod. \texttt{userPassword}}
        node[pos=0.96,above,port] {389};
  
    \draw[->,route] (MSA) edge
         node[above,proto]        {ESMTP}
         node[pos=0.9,below,port] {25}
                    (MTA);

    \draw[->, route]
            (MSA.west)
            .. controls +(-2.5cm,0) and +(2.5cm,0) ..
            (LDAP-producer.east)
        node[pos=0.5,above,proto] {LDAP \textnormal{(over \texttt{SSH})}}
        node[pos=0.5,below,what]  {auth. bind}
        node[pos=0.96,below,port] {389};

    \draw[->,route] (SMTP-server)   edge[TODO]
        node[above,proto]         {LDAPI}
        node[below,what]          {virtual lookups}
                    (LDAP-consumer) edge
        node[above,proto]         {ESMTP \textnormal{(over \texttt{SSH})}}
        node[pos=0.96,below,port] {25}
                    (SMTP-server-IMAP);

    \draw[->,route] (SMTP-server-IMAP) edge
        node[above,proto]         {LDAP}
        node[below,what]          {virtual lookups}
        node[pos=0.92,above,port] {389}
                    (LDAP-producer)    edge
        node[below,what]          {\texttt{deliver}}
                    (IMAP-server);

    \draw[->,route] (IMAP-server) edge
        node[below,what] {read,write}
                    (mailboxes);

    \draw[->,route] (LDAP-consumer) edge
        node[above,proto]         {LDAP \textnormal{(over \texttt{SSH})}}
        node[below,what]          {\texttt{syncrepl}}
        node[pos=0.95,above,port] {389}
           (LDAP-producer);

    \draw[->,route,TODO]
            (webmail.east)
            .. controls +(3.5cm,0) and +(0,-4cm) ..
            (MTA.south)
        node[pos=0.5,above,proto] {ESMTPS}
        node[pos=0.5,below,what]  {\texttt{sendmail}}
        node[pos=0.98,above,port] {25};
  \end{pgfonlayer}


  \begin{pgfonlayer}{background}
    \draw[->,route,path fading=north]
          ($(SMTP-server.west)+(-5cm,2cm)$)
          .. controls +(2cm,0) and +(-2cm,0) ..
          (SMTP-server.west);
  \end{pgfonlayer}
  \path[draw=none]
        ($(SMTP-server.west)+(-5cm,2cm)$)
        .. controls +(2cm,0) and +(-2cm,0) ..
        (SMTP-server.west)
    node[pos=0.5,above,proto] {ESMTP}
    node[pos=0.97,above,port] {25};
  
  \begin{pgfonlayer}{background}
    \draw[->,route,TODO,path fading=south]
       (MTA.east)
       .. controls +(2cm,0) and +(0,2cm) ..
       ($(MTA.east)+(2cm,-5cm)$);
  \end{pgfonlayer}
  \path[TODO,draw=none]
      (MTA.east)
      .. controls +(2cm,0) and +(0,2cm) ..
      ($(MTA.east)+(2cm,-5cm)$)
    node[pos=0.5,above,proto] {ESMTP};
\end{tikzpicture}
\vspace*{\fill}

\end{document}
