Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: HowTo: make XSane and Gmail play nice

  1. #1
    Join Date
    Dec 2005
    Beans
    89

    Lightbulb HowTo: make XSane and Gmail play nice

    XSane has a scan-to-email facility that knows how to talk to an SMTP server. Gmail uses an SMTP server that requires a secure (SSL) connection. XSane's SMTP support doesn't do SSL. I didn't want to install and configure a full-blown MTA like Postfix or Exim just to make these things work together. Here's what I did instead.

    First thing is to make sure the necessary packages are installed:
    Code:
    sudo apt-get install openssl xinetd
    Next, create a little wrapper to talk to the Gmail SMTP server without injecting extra text we don't want:
    Code:
    sudo tee /usr/bin/gmail-smtp <<EOF >/dev/null
    #!/bin/sh
    /usr/bin/openssl s_client -connect smtp.gmail.com:465 -quiet 2>/dev/null
    EOF
    sudo chmod +x /usr/bin/gmail-smtp
    Test the connection:
    Code:
    gmail-smtp
    After a short delay, you should see something like
    220 mx.google.com ESMTP f42sm17489123rvb.6
    If you then type
    helo
    you should get something like
    250 mx.google.com at your service
    and typing
    quit
    should get you
    221 2.0.0 mx.google.com closing connection f42sm17489123rvb.6
    and your shell prompt back.

    Now we need to make that wrapper available as a local network service, so XSane can use it:
    Code:
    sudo tee /etc/xinetd.d/gmail-smtp <<EOF >/dev/null
    # default: on
    # description: Gmail SMTP wrapper for clients without SSL support
    service gmail-smtp
    {
        disable         = no
        bind            = localhost
        port            = 10025
        socket_type     = stream
        protocol        = tcp
        wait            = no
        user            = root
        server          = /usr/bin/gmail-smtp
        type            = unlisted
    }
    EOF
    sudo /etc/init.d/xinetd reload
    The output of
    Code:
    netstat -ltn
    should now include a line that looks like this:
    tcp 0 0 127.0.0.1:10025 0.0.0.0:* LISTEN
    and
    Code:
    telnet localhost 10025
    should get you a conversation with Gmail's SMTP server like the one you had above.

    All that remains is to configure XSane. Under the Email tab in the Setup menu, set the SMTP server address to localhost, the port to 10025, fill in your Gmail account details, and select ASMTP Login authorization.

    I'm subscribed to this thread in case you have trouble. Enjoy!

  2. #2
    Join Date
    Aug 2007
    Beans
    9

    Re: HowTo: make XSane and Gmail play nice

    A fantastic & easy guide ! Thank you very much.

  3. #3
    Join Date
    Nov 2009
    Beans
    2

    Re: HowTo: make XSane and Gmail play nice

    Thank-you so much for publishing this guide and sharing this information!!!!!! I used it to create a connection to yahoo mail as well.

    I followed the procedure exactly, replacing gmail-smtp with yahoo-smtp and it works!

    Xsane now is able to send scanned images to recipients via SSL on yahoo mail.

  4. #4
    Join Date
    Aug 2010
    Beans
    1

    Re: HowTo: make XSane and Gmail play nice

    Extremely well written, concise and helpful!
    Thank you very much for your help, and btw: that was SO phat how you figured out that the underlying problem was SSL
    -

    For Me: Another giant step away from Winblows
    For You: Beers on me if ever we perchance should meet!

  5. #5
    Join Date
    Nov 2007
    Beans
    7

    Re: HowTo: make XSane and Gmail play nice

    Great work!!! Thank you.

    In my server openssl go to 100% cpu, to avoid this i suggest to change (/usr/bin/gmail-smtp):

    #!/bin/sh
    /usr/bin/killgmail&
    /usr/bin/openssl s_client -connect smtp.gmail.com:465 -quiet 2>/dev/null


    and create the file (/usr/bin/killgmail) :

    #!/bin/sh
    sleep 10
    killall openssl


    and then make it exec:

    chmod +x /usr/bin/killgmail

    With this mod openssl is terminated after 10 sec ... is enough to send 1 mail.
    Of course this solution is a bad idea if you have concurrent openssl sessions.
    Last edited by fcorades; August 21st, 2010 at 05:52 PM.

  6. #6
    Join Date
    Aug 2005
    Location
    Ontario, Canada
    Beans
    93

    Re: HowTo: make XSane and Gmail play nice

    Quote Originally Posted by fcorades View Post
    Great work!!! Thank you.

    In my server openssl go to 100% cpu, to avoid this i suggest to change
    I have the same problem.
    I guess the more important question would be why is it doing this? Seems like some kind of bug.

  7. #7
    Join Date
    Dec 2005
    Beans
    89

    Re: HowTo: make XSane and Gmail play nice

    I have not seen this behavior, so I can't help much with the bug. But I'd like to offer the following alternative workaround, which is a little less convoluted and avoids using "killall" (I've never been a fan of risking the death of more processes than necessary).

    Replace the gmail-smtp script creation step from my original post with this:
    Code:
    sudo tee /usr/bin/gmail-smtp <<EOF >/dev/null
    #!/bin/sh
    exec 3>&0
    /usr/bin/openssl s_client -connect smtp.gmail.com:465 -quiet 2>/dev/null 0<&3 &
    sleep 10
    kill $! 2>/dev/null
    EOF
    sudo chmod +x /usr/bin/gmail-smtp
    In the initial testing stages you might want to replace the "sleep 10" with something more generous.

  8. #8
    Join Date
    Aug 2005
    Location
    Ontario, Canada
    Beans
    93

    Re: HowTo: make XSane and Gmail play nice

    Quote Originally Posted by flabdablet View Post
    Replace the gmail-smtp script creation step from my original post with this:
    Your alternative doesn't appear to function for some reason.
    This bug is occurring on 3 separate computers that I have.
    Openssl continues to run at 100% and more instances spawn each time an e-mail is sent.
    I can only see the process running under the "top" command and not under "System"-->"Administration"-->"System Monitor"-->"Processes(tab)".

    And yes, I feel icky using "killall".
    Last edited by High Roller; August 25th, 2010 at 01:43 AM.

  9. #9
    Join Date
    Dec 2005
    Beans
    89

    Re: HowTo: make XSane and Gmail play nice

    Weird.

    What happens if you exercise gmail-smtp directly, and what happens via telnet?

  10. #10
    Join Date
    Aug 2005
    Location
    Ontario, Canada
    Beans
    93

    Re: HowTo: make XSane and Gmail play nice

    Quote Originally Posted by flabdablet View Post
    Weird.

    What happens if you exercise gmail-smtp directly, and what happens via telnet?
    When I use gmail-smtp as described in your how-to the "openssl" process ends after I type "quit".

    When I use telnet as described in your how-to the "openssl" process remains active even after telnet has been closed.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •