Connecting a gmail account and sending email as that gmail user

I’d like to allow users to connect their gmail account such that they can send (and receive) emails from that gmail account within the application.

Looks like full IMAP integration or using the Gmail API might be the two best routes.

Has anyone had success doing something like this or have any opinions on the best approach?