Skip to content

Commit

Permalink
Add support for from field for sending messages (#386)
Browse files Browse the repository at this point in the history
Added support for a from field in SendMessageRequest.
  • Loading branch information
mrashed-dev authored Sep 24, 2024
1 parent 7757cc6 commit f30867b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ nylas-python Changelog

Unreleased
----------------
* Add support for from field for sending messages
* Fix IMAP identifiers not encoding correctly
* Add missing schedule-specific fields to Message model

Expand Down
2 changes: 2 additions & 0 deletions nylas/models/drafts.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ class SendMessageRequest(CreateDraftRequest):
reply_to_message_id (NotRequired[str]): The ID of the message that you are replying to.
tracking_options (NotRequired[TrackingOptions]): Options for tracking opens, links, and thread replies.
custom_headers(NotRequired[List[CustomHeader]]): Custom headers to add to the message.
from_: The sender of the message.
use_draft: Whether or not to use draft support. This is primarily used when dealing with large attachments.
"""

from_: NotRequired[List[EmailName]]
use_draft: NotRequired[bool]
3 changes: 3 additions & 0 deletions nylas/resources/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ def send(
form_data = None
json_body = None

# From is a reserved keyword in Python, so we need to pull the data from 'from_' instead
request_body["from"] = request_body.get("from_", None)

# Use form data only if the attachment size is greater than 3mb
attachment_size = sum(
attachment.get("size", 0)
Expand Down

0 comments on commit f30867b

Please sign in to comment.