Looks as if the email was sent successfully so far. You should remove the debugging code, its way too much information and post the normal output from the mail log plus the output of the command "netstat -tap".
netstat -tap Code: Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 localhost:10024 *:* LISTEN 2328/amavisd (maste tcp 0 0 localhost:10025 *:* LISTEN 3167/master tcp 0 0 *:mysql *:* LISTEN 2403/mysqld tcp 0 0 localhost:spamd *:* LISTEN 2491/spamd.pid tcp 0 0 *:ftp *:* LISTEN 3181/pure-ftpd (SER tcp 0 0 server.domain.:domain *:* LISTEN 3094/mydns tcp 0 0 localhost:domain *:* LISTEN 3094/mydns tcp 0 0 *:ssh *:* LISTEN 2300/sshd tcp 0 0 *:smtp *:* LISTEN 3167/master tcp 0 0 localhost:mysql localhost:36927 ESTABLISHED 2403/mysqld tcp 0 0 localhost:mysql localhost:47592 ESTABLISHED 2403/mysqld tcp 0 0 localhost:47592 localhost:mysql ESTABLISHED 22422/amavisd (ch18 tcp 0 0 localhost:36927 localhost:mysql ESTABLISHED 22600/amavisd (ch17 tcp 0 300 server.domainname.ca:ssh S0106001fd0d7975e:57177 ESTABLISHED 9810/sshd: <adminaccount> tcp6 0 0 [::]:imaps [::]:* LISTEN 3051/couriertcpd tcp6 0 0 [::]:pop3s [::]:* LISTEN 3089/couriertcpd tcp6 0 0 [::]:pop3 [::]:* LISTEN 3067/couriertcpd tcp6 0 0 [::]:imap2 [::]:* LISTEN 3029/couriertcpd tcp6 0 0 [::]:http-alt [::]:* LISTEN 3328/apache2 tcp6 0 0 [::]:www [::]:* LISTEN 3328/apache2 tcp6 0 0 [::]:ftp [::]:* LISTEN 3181/pure-ftpd (SER tcp6 0 0 2002:d179:c665:0:domain [::]:* LISTEN 3094/mydns tcp6 0 0 ip6-localhost:domain [::]:* LISTEN 3094/mydns tcp6 0 0 [::]:ssh [::]:* LISTEN 2300/sshd tcp6 0 0 [::]:https [::]:* LISTEN 3328/apache2 tcp6 0 0 server.domainname.c:imaps S0106001fd0d7975e:54274 ESTABLISHED 5535/couriertls tcp6 0 0 server.domainname.c:imaps S0106001fd0d7975e:55873 ESTABLISHED 9311/couriertls tcp6 0 0 server.domainname.c:imaps S0106001fd0d7975e:55874 ESTABLISHED 9330/couriertls tcp6 0 0 server.domainname.c:imaps S0106001fd0d7975e:55844 ESTABLISHED 9168/couriertls tcp6 0 0 server.domainname:imaps 192.168.0.1%809035:4704 ESTABLISHED 5553/couriertls tcp6 0 0 server.domainname.c:imaps 192.168.0.1%809035:4625 ESTABLISHED 5412/couriertls The email isn't sent though, and the client errors out.