Send a NEW outbound email to a recipient who is not already in the active email thread. Do NOT use to reply on an inbound email thread — the email channel replies automatically with your final assistant message.
Send emails via the Gmail API using src.channels.gmail through bash.
The sender address is $GOOGLE_DELEGATED_USER, configured at the environment level.
If the current conversation arrived over the email channel (the user message
begins with [channel: email, ...]), the email channel will automatically send
your final assistant message as a reply in that thread. Do not also call
send_reply from this skill — you will send two emails. Just write your reply
as your normal final response; the channel delivers it.
Use this skill only for:
python3 -c "
from src.channels.gmail import build_service, send_email
import os
service = build_service(os.environ['GOOGLE_SERVICE_ACCOUNT_FILE'], os.environ['GOOGLE_DELEGATED_USER'])
send_email(to='[email protected]', subject='Subject line', body='Plain text body here', service=service)
print('Sent.')
"
Provide both plain text and HTML — the recipient's client chooses which to display:
python3 -c "
from src.channels.gmail import build_service, send_email
import os
service = build_service(os.environ['GOOGLE_SERVICE_ACCOUNT_FILE'], os.environ['GOOGLE_DELEGATED_USER'])
send_email(
to='[email protected]',
subject='Subject line',
body='Plain text fallback',
body_html='<h1>Hello</h1><p>Rich content here</p>',
service=service,
)
print('Sent.')
"
For long content, write to a temp file first, then read it in:
python3 -c "
from src.channels.gmail import build_service, send_email
import os
service = build_service(os.environ['GOOGLE_SERVICE_ACCOUNT_FILE'], os.environ['GOOGLE_DELEGATED_USER'])
with open('/tmp/email-body.txt') as f:
body = f.read()
send_email(to='[email protected]', subject='Subject line', body=body, service=service)
print('Sent.')
"
python3 -c "
from src.channels.gmail import build_service, send_email
import os
service = build_service(os.environ['GOOGLE_SERVICE_ACCOUNT_FILE'], os.environ['GOOGLE_DELEGATED_USER'])
send_email(
to='[email protected],[email protected]',
cc='[email protected]',
bcc='[email protected]',
subject='Subject line',
body='Content',
service=service,
)
print('Sent.')
"
python3 -c "
from src.channels.gmail import build_service, send_email
import os
service = build_service(os.environ['GOOGLE_SERVICE_ACCOUNT_FILE'], os.environ['GOOGLE_DELEGATED_USER'])
send_email(
to='[email protected]',
subject='Report attached',
body='See attached.',
attachments=['/path/to/report.pdf', '/path/to/data.csv'],
service=service,
)
print('Sent.')
"
When replying to an existing email thread, use send_reply with the original message ID:
python3 -c "
from src.channels.gmail import build_service, send_reply
import os
service = build_service(os.environ['GOOGLE_SERVICE_ACCOUNT_FILE'], os.environ['GOOGLE_DELEGATED_USER'])
send_reply(
to='[email protected]',
subject='Re: Original subject',
body='Reply content',
reply_to_message_id='MESSAGE_ID',
service=service,
)
print('Sent.')
"
python3 -c.