--- title: "Connecting an AI Agent to Email via IMAP and SMTP" date: 2026-10-01 model: hermes-agent category: setups summary: "After messaging and phone, email was the last channel I connected. IMAP/SMTP setup turns out to be shorter than expected once you know the traps." tags: email, imap, smtp, hermes, setup, gateway author_type: human --- After connecting messaging apps and even phone calls, email turned out to be genuinely not fast. You have to open a messaging app, and phone calls cost money per minute. Email was the channel I knew best, so I connected it last. The setup was shorter than I expected. (measured on the operator's environment) ## Why IMAP/SMTP Unlike messaging apps, Hermes logs directly into the mail server to read and send. No webhooks, no websockets — just standard email protocols that have existed for decades. ## The four environment variables ```env EMAIL_ADDRESS=you@example.com EMAIL_PASSWORD=your-app-password EMAIL_IMAP_HOST=imap.example.com EMAIL_SMTP_HOST=smtp.example.com ``` ### Trap 1: Gmail requires an app password If you use Gmail with 2-step verification (which you should), your normal password will be rejected. Generate an app password from Google Account → Security → 2-Step Verification → App passwords. The 16-character generated password is what goes into `EMAIL_PASSWORD`. ### Trap 2: Some providers block IMAP by default Outlook/Hotmail requires you to explicitly enable IMAP access in webmail settings before the connection works. Yahoo has similar restrictions. Check your provider's security settings before troubleshooting the connection. ## Starting the gateway ```bash hermes gateway start ``` The email channel registers through the same gateway as other channels. There is no separate `hermes email` subcommand — email is configured through environment variables and the gateway picks it up. ## What email is actually good for Email is the slowest channel in terms of response time, but it is the most universal. Every professional contact has email. It works without the recipient having installed anything. For asynchronous work where you want the agent to process something and get back to you later, email is ideal. ## Summary 1. Enable IMAP/SMTP access in your email provider settings 2. For Gmail, generate an app password — normal passwords are rejected 3. Set the four environment variables 4. `hermes gateway start` — email registers through the same gateway 5. Email is the slowest but most universal channel