> For the complete documentation index, see [llms.txt](https://cylexdev.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cylexdev.gitbook.io/docs/cylex-phone/exports-and-events/server-exports/mail.md).

# Mail

#### sendMail  <a href="#user-content-sendmail-server-side" id="user-content-sendmail-server-side"></a>

```lua
-- identifier: string - target citizenid/identifier
-- src: number | nil - target player source (if online, triggers a sound/notification. Pass nil if offline)
-- data: table - mail content
-- return: table | nil - Returns the updated mails table if successful

-- Sends an email to the specified player's Mail app.

local mailData = {
    sender = "Los Santos Police Department",
    subject = "Speeding Ticket Notification",
    message = "You have been caught speeding on Route 68. A fine of $500 has been issued.",
    -- 'date' and 'id' are automatically generated by the script, no need to include them.
}

-- Usage if player is online (will trigger a phone notification):
exports['cylex_phone']:sendMail(identifier, src, mailData)

-- Usage if player is offline (silently adds to their phone):
exports['cylex_phone']:sendMail(identifier, nil, mailData)
```
