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:
Next, create a little wrapper to talk to the Gmail SMTP server without injecting extra text we don't want:
sudo apt-get install openssl xinetd
Test the connection:
sudo tee /usr/bin/gmail-smtp <<EOF >/dev/null
/usr/bin/openssl s_client -connect smtp.gmail.com:465 -quiet 2>/dev/null
sudo chmod +x /usr/bin/gmail-smtp
After a short delay, you should see something like
220 mx.google.com ESMTP f42sm17489123rvb.6
If you then type
you should get something like
250 mx.google.com at your service
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:
The output of
sudo tee /etc/xinetd.d/gmail-smtp <<EOF >/dev/null
# default: on
# description: Gmail SMTP wrapper for clients without SSL support
disable = no
bind = localhost
port = 10025
socket_type = stream
protocol = tcp
wait = no
user = root
server = /usr/bin/gmail-smtp
type = unlisted
sudo /etc/init.d/xinetd reload
should now include a line that looks like this:
tcp 0 0 127.0.0.1:10025 0.0.0.0:* LISTEN
should get you a conversation with Gmail's SMTP server like the one you had above.
telnet localhost 10025
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!