Implementation of an EmailClient for Eliza.
The following settings will be declared on your environment variable or inside your agent' settings:
EMAIL_OUTGOING_SERVICE: "smtp" | "gmail"EMAIL_OUTGOING_HOST: SMTP Hostname or IP to connect to. Required only when "smtp" service is configured.EMAIL_OUTGOING_PORT: the port to connect to (defaults to 465 for secure connections, otherwise 587). Required only if "smtp" is configured.EMAIL_SECURE: if true the connection will use TLS, otherwise TLS will be used if server supports STARTTLS extension. Set to true if port 465 is selected.EMAIL_OUTGOING_USER: UsernameEMAIL_OUTGOING_PASS: Password. If "gmail" selected you will need to provision a dedicated password for the agent [1]
EMAIL_INCOMING_SERVICE: "imap"EMAIL_INCOMING_HOST: IMAP Hostname or IP to connect toEMAIL_INCOMING_PORT: the port to connect to (defaults to 993)EMAIL_INCOMING_USER: UsernameEMAIL_INCOMING_PASS: Password
[1] https://support.google.com/mail/answer/185833?hl=en
- Install the Plugin: First, import the plugin into your agent by running the following command:
pnpm add @elizaos/plugin-email
- Send Emails: You can send emails using the following method:
this.runtime.clients.email.send({
to: "[email protected]",
subject: "Your Subject Here",
text: "Your email body here."
});
- Receive Emails: To receive emails, register a callback function that will be invoked when an email is received:
this.runtime.clients.email.receive((email) => {
console.log("Email Received:", email);
});