Using Pipedream's IMAP API, developers can automate interactions with their email inbox, enabling serverless workflows that perform actions based on incoming emails. This could include parsing email contents, triggering events upon receiving emails from specific senders, attaching labels, and much more. By leveraging IMAP, Pipedream can act as a bridge between your email and other services, streamlining processes that would otherwise require manual intervention.
import { once } from "events";
import imaps from "imap-simple";
import cycle from "cycle";
export default defineComponent({
props: {
imap: {
type: "app",
app: "imap",
}
},
async run({steps, $}) {
const { host, port, email, password } = this.imap.$auth;
const connection = await imaps.connect({
imap: {
host,
port,
user: email,
password,
tls: true,
tlsOptions: { servername: host },
authTimeout: 3000
},
});
const boxes = await connection.getBoxes();
// Filter out circular references to parents
const filteredBoxes = cycle.decycle(boxes);
$.export("results", filteredBoxes);
connection.end();
await once(connection.imap, "end");
},
})
Email Attachment Extraction and Storage: Automatically detect when a new email with attachments arrives in your inbox. Download the attachments and save them to a cloud storage service like Google Drive or Dropbox using Pipedream's built-in connectors.
Customer Support Ticket Creation: Upon receiving an email to a support inbox, use Pipedream to parse the email, extract relevant information (like the sender's email, subject, and body), and create a ticket in a customer support platform such as Zendesk or Help Scout.
Lead Qualification: When a new lead submits information via email, Pipedream can parse the email content and use it to populate fields in a CRM like Salesforce. Additionally, it can trigger a workflow that scores the lead's quality and assigns it to the appropriate sales team member.
IMAP uses API keys for authentication. When you connect your IMAP account, Pipedream securely stores the keys so you can easily authenticate to IMAP APIs in both code and no-code steps.
Below are the required fields to connect your IMAP account to Pipedream:
host
: Enter the host Pipedream should connect to. Refer to your email provider's IMAP instructions if you aren't sure what to enter.email
: Enter the email address you use to sign in to the account you'd like to connect.password
: This is the password you use to sign in to your email account. Note: in order to connect a Gmail account, you must use an App Password.port
: Specify the port number, either 143
(default) or 993
. Refer to your email provider's IMAP instructions if you aren't sure which to use.For Gmail accounts, refer to these instructions.