go and gmail?

467 views
Skip to first unread message

Jim Robinson

unread,
Mar 29, 2013, 5:43:17 PM3/29/13
to golan...@googlegroups.com
Has anyone here written go programs that can talk to gmail,
e.g., through imap or smtp?

With the upcoming forced migration to the 'new compose'
feature I'm looking at how I can still browse/search email
via the gmail web interface but compose emails using an
external editor.

Right now I have a little go server that a chrome extension
named TextAid talks to, and I thought about seeing whether
or not I could rework it to talk directly to the gmail servers.

It looks as though there are a few go imap libraries available,
does anyone have experience enough to recommend one?

Jim

Scott Lawrence

unread,
Mar 29, 2013, 5:48:10 PM3/29/13
to Jim Robinson, golan...@googlegroups.com
smtp is in the standard library: http://golang.org/pkg/net/smtp/

As usual, I'll plug my pop3 and mail parsing implementations:

https://github.com/bytbox/go-pop3
https://github.com/bytbox/go-mail

>
> Jim
>
> --
> You received this message because you are subscribed to the Google Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

--
Scott Lawrence

go version go1.0.3
Linux baidar 3.8.3-2-ARCH #1 SMP PREEMPT Sun Mar 17 13:04:22 CET 2013 x86_64 GNU/Linux

Maxim Khitrov

unread,
Mar 29, 2013, 6:11:21 PM3/29/13
to Jim Robinson, golan...@googlegroups.com
On Fri, Mar 29, 2013 at 5:48 PM, Scott Lawrence <byt...@gmail.com> wrote:
> On Fri, 29 Mar 2013, Jim Robinson wrote:
>
>> Has anyone here written go programs that can talk to gmail,
>> e.g., through imap or smtp?
>>
>> With the upcoming forced migration to the 'new compose'
>> feature I'm looking at how I can still browse/search email
>> via the gmail web interface but compose emails using an
>> external editor.
>>
>> Right now I have a little go server that a chrome extension
>> named TextAid talks to, and I thought about seeing whether
>> or not I could rework it to talk directly to the gmail servers.
>>
>> It looks as though there are a few go imap libraries available,
>> does anyone have experience enough to recommend one?
>
>
> smtp is in the standard library: http://golang.org/pkg/net/smtp/
>
> As usual, I'll plug my pop3 and mail parsing implementations:
>
> https://github.com/bytbox/go-pop3
> https://github.com/bytbox/go-mail

And I'll add my imap library, though you don't really need it for
composing messages (unless you want to upload drafts):

https://code.google.com/p/go-imap/

It's fairly low-level and assumes familiarity with the relevant RFCs.
The demo scripts are a good starting point for learning the protocol.

- Max

Jim Robinson

unread,
Mar 29, 2013, 6:16:43 PM3/29/13
to golan...@googlegroups.com, Jim Robinson
Cool, thank you both for the recommendations.  I was thinking
that surfacing the 'drafts' folder in some manner would be my
preferred solution, falling back to just sending via smtp as my
fallback.

Maxim Khitrov

unread,
Mar 29, 2013, 6:32:11 PM3/29/13
to Jim Robinson, golan...@googlegroups.com
On Fri, Mar 29, 2013 at 6:16 PM, Jim Robinson <jim.ro...@gmail.com> wrote:
> Cool, thank you both for the recommendations. I was thinking
> that surfacing the 'drafts' folder in some manner would be my
> preferred solution, falling back to just sending via smtp as my
> fallback.

Sending can only be done through smtp, and you might have to use your
ISP's smtp server for this. You can use imap to look at what is on the
server and to upload, but not send, new messages.

Your composing application can use the imap library to periodically
save the drafts. Assuming you're using the English interface, these
will be in the "[Gmail]/Drafts" mailbox. Once the message is sent via
smtp, you can move the final version from "[Gmail]/Drafts" to
"[Gmail]/Sent Mail". To be more robust, you should use RFC 6154 flags
(\Drafts and \Sent) to identify the special-use mailboxes. More
information is here:

https://developers.google.com/google-apps/gmail/imap_extensions#special-use_extension_of_the_list_command

- Max
Reply all
Reply to author
Forward
0 new messages