Super User is a question and answer site for computer enthusiasts and power users. 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 have a SSH access to the server with working sendmail provided by my hoster. I want to configure my local sendmail to use remote server as a relay. How can I do that? Is it posiible at all?

Note: I can write script to run something like ssh user@host sendmail ... but it seems to me like there is a better solution.

share|improve this question
up vote 1 down vote accepted

Prepare SSH

Locally, create a new SSH key without password. In these examples, it will be located at /etc/mail/ssh-sendmail-key and owned by the MAILUSER user. Change MAILUSER to whatever Unix account your local system uses: postfix, sendmail, mail, ... Using root or nobody is not recommended.

# ssh-keygen -f /etc/mail/ssh-sendmail-key -N ""
# chown MAILUSER /etc/mail/ssh-sendmail-key{,.pub}

Append the contents of /etc/mail/ to the server's *authorized_keys* file:

ssh-rsa AAAA....


Create a ssh transport in

ssh    unix    -       n       n       -       -       pipe
    user=MAILUSER argv=/usr/bin/ssh -i /etc/mail/ssh-sendmail-key myhostserver /usr/sbin/sendmail -i $recipient

In, add:

default_transport = ssh



    driver = manualroute
    domains = ! +local_domains
    transport = ssh
    route_list = * foo


    driver = pipe
    user = MAILUSER
    command = /usr/bin/ssh -i /etc/mail/ssh-sendmail-key myhostserver /usr/sbin/sendmail -i $RECIPIENT
share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.