TomatoUSB, my domain, SMTP, and gmail ?

Discussion in 'Tomato Firmware' started by samwathegreat, Dec 1, 2012.

  1. samwathegreat

    samwathegreat Serious Server Member

    Hi guys,

    I realize that the thread title is a little lacking, so this is what I'm trying to accomplish:

    1. I already have a few domains self-hosted on my IP. Very very little traffic to these websites. Obviously, I have the A record for each domain pointing to my IP. Web server has been configured properly and it works fine.

    I do NOT want to pay for hosting - this is the whole point of configuring this way.

    2. My registar offers FREE email forwarding - I can set up any address * to forward to my personal gmail account.

    Again, this works great.

    3. I'm unable to send email from . Obviously, this is because I don't have an SMTP server set up to deliver outgoing mail.

    Gmail offers settings in "Accounts and Import" section where I can add an email address I own. If I do this, I can send email, but all email sent shows that it was "sent on behalf of by gmail" and doesn't show as originating from my domain.

    The way to get around this, is to give gmail credentials for my SMTP server (and gmail will ONLY use SSL/TLS), allow gmail to connect to my SMTP server and send the mail through. Then it should show as originating from my domain.

    I've had this working before, when I used hosted email, it was very simple to put in the credentials and it worked as it should.

    4. Since I'm not using hosted email, and trying to self-host everything in my domains, I'd like to get some kind of VERY SIMPLE SMTP server set up on Tomato that gmail can connect to, log in (ssl/tls) and send the mail through. Sounds simple enough, but I'm not sure where to start.

    I do NOT need anything other than SMTP. NO mail is to be received, so no pop3, imap, etc. I JUST need to configure SMTP.

    I'd really appreciate some help getting this configured. Again, there is very very little traffic on my domains, so I'm not concerned that there won't be enough 'horsepower' in tomato to accomplish this.

    I like the way email forwarding is set up now, and would prefer not to change it. I only need to be able to SEND mail.

    Other thoughts:

    I've read alot about MX records, etc. Right not, my MX records are pointing to the email forwarding service. The way I understand it is that as long as the mail originates from the A record on my domain, that receiving servers should accept it, even though it doesn't match the MX records. I don't think I should need to mess with my domain records at all to get this to work.

    I've checked out "sendmail", already bundled with tomato, but find it very confusing to work with. I've also tried installing "postfix", but one of its dependencies conflicts with a library that's already installed - wasn't able to install it.

    I also checked out "xmail", which is available in optware. I was able to install it, but configuring it looks to be a nightmare.

    It seems that this should be pretty straightforward. First, I need to set up an SMTP server and get it working, then generate certificates for TLS, add credentials for gmail to be able to connect to my SMTP server, then I'm thinking I should be all set. Gmail will show a drop-down box where I can select the "FROM:" field, and set it to either my gmail address, or one on my domain.

    Any advice?

  2. mstombs

    mstombs Network Guru Member

  3. samwathegreat

    samwathegreat Serious Server Member

    Unfortunately, looks like a catastrophic event has put the files offline. Hopefully Rodney had a backup of those files...
  4. mstombs

    mstombs Network Guru Member

  5. samwathegreat

    samwathegreat Serious Server Member

    Yep, this one works. Didn't see sendmail in there though. I saw postfix, but I'm not sure if that's what I should try.

    Since Rodney has experience with this, hopefully he will chime in when he's not busy.
  6. rhester72

    rhester72 Network Guru Member

    I'm using openssl as the busybox/sendmail shim and busybox getopt (NOT compiled into the Tomato busybox, you'll need mine or another more complete one) to save my sanity. Edit to taste. CApath is _not_ required, I use it only for completeness (if you have access to the full Mozilla cert store).

    Use the script just like standard mail - in fact, mine is in /opt/usr/bin/mail.

    usage() {
      echo "Usage: `basename $0` [-h help] -s subject address@domain"
    GETOPT=`/opt/bin/getopt -o hs: -n $(basename $0) -- "$@"`
    if [ $? != 0 ]; then exit 1; fi
    eval set -- "$GETOPT"
    while true; do
      case $1 in
          shift 2
    if [[ -z "$SUBJECT" ]] || [[ -z "$TO" ]]; then
    if test -t 0; then
    echo "To: $TO" > $TEMPFILE
    echo "Subject: $SUBJECT" >> $TEMPFILE
    echo "" >> $TEMPFILE
    cat - >> $TEMPFILE
    cat $TEMPFILE | /usr/sbin/sendmail -f<YOUR_GMAIL_ADDRESS> -H 'exec /opt/usr/bin/openssl s_client -quiet -starttls smtp -CApath /opt/etc/ssl/certs -connect 2>/dev/null' -au<YOUR_GMAIL_ID> -ap<YOUR_GMAIL_PASSWORD> 2>/dev/null
    rm $TEMPFILE
    exit $RC
  7. samwathegreat

    samwathegreat Serious Server Member

    Thanks for the reply Rodney,

    It looks like I'm trying to do the reverse, however. I want gmail to be able to connect to my smtp server to send mail out. I haven't even gotten so far as to set up a working smtp server yet, let alone set up TLS for gmail to be able to connect.

    Is this feasible?
  8. rhester72

    rhester72 Network Guru Member

    Not easily.

    I've yet to find a lightweight smtp gateway. I came VERY close to getting postfix going once, but the sheer effort involved in a completely manual setup put off even me and I finally gave up from frustration and lack of free time. I'd quite like to have some sort of very light smtp forwarder myself.

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice