Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use a SOCKS proxy server to send mail using sendmail in Linux and mailx to send mails from the command line.

To make use of the SOCKS server, I am using tsocks to send mails using mailx, for example like this

tsocks mailx -s "Test mail" valid_mail_address@gmail.com

But the mails I send are not going through the proxy. I don't know what I do wrong.

Any help please.

share|improve this question

migrated from stackoverflow.com May 10 '12 at 10:39

This question came from our site for professional and enthusiast programmers.

Could you paste the output of tsocks mailx -v -s "Test mail" valid_mail_address@gmail.com ? That would help understand what's going on. – Frederik Deweerdt May 10 '12 at 14:24

I suspect mailx is configured to use sendmail so tsocks is redundant here. What happens if you omit it?

tsocks may actually be in the way - if you don't have a rule in /etc/tsocks.conf to bypass the proxy for the loopback interface it could send the message to the proxy when it shouldn't.

share|improve this answer

Late answer, but I just figured out how to send emails through the http/https only proxy:

Using only ssmtp and following the archlinux wiki setup. The tutorial fails at the sending of the test mail, below is the solution which works for me.

I have a ssh socks connection to localhost. I'm using corkscrew to connect to my ssh daemon running on port 443. You may or may not need this. If you don't need this omit the -o option below

ssh -vv -CND 8080 -p443 user@<sshd server> -o "ProxyCommand corkscrew 
   $proxy_ip_or_domain_name $proxy_port <sshd server> 
   443 /file/to/proxy-credentials"

the proxy-credentials authorization file looks like this:


I have configured /etc/tsocks.conf like this

server =
server_port = 8080

The tutorial command

echo test | mail -v -s "testing ssmtp setup" username@somedomain.com

hangs and doesn't work for me when putting tsocks in front of it, but

TSOCKS_CONFFILE=/etc/tsocks.conf tsocks mail username@somedomain.com 
    < .bash_history


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.