POST /v2/mailings
Create a new mail
Create a new, authenticated mail, from 42.
live_help Notes
assignment
This action requires one of theses roles:
Advanced tutor
, Avanced staff
settings Params
Param name | Description |
---|---|
mailing | optional , nil allowed . Must be a Hash |
mailing[subject] |
required
. Must be String
The subject of the mail |
mailing[content] |
required
. Must be String
The content of the mail, supports Markdown. |
mailing[from] |
required
. Must be String
The mail sender, with the |
mailing[to] |
optional
, nil allowed
. Must be an array of any type
An array of emails for the mail’s |
mailing[cc] |
optional
, nil allowed
. Must be an array of any type
An array of emails for the mail’s |
mailing[bcc] |
optional
, nil allowed
. Must be an array of any type
An array of emails for the mail’s |
mailing[title] |
optional
, nil allowed
. Must be String
The title of the mail. If none, set to the subject |
mailing[subtitle] |
optional
, nil allowed
. Must be String
The subtitle of the mail |
mailing[identifier] |
optional
, nil allowed
. Must be String
The identifier of the mail, used with meta |
mailing[meta] |
optional
, nil allowed
. Must be Hash
The meta of the mail |
at |
optional
. Must be DateTime
The time to send the mail. If none, send it now. |
Examples
POST /v2/mailings
{
"mailing": {
"content": "Hi andre,\nYou just *won* the mego jackpot !\nCheck [this link](http://spam.prizepool-game-lottery.xxx/winner.php)",
"from": "[email protected]",
"identifier": "an_unique_identifier",
"subject": "You are the super online contest winner !!!",
"subtitle": "And it's kinda awesome",
"title": "You won the big jackpot",
"to": [
"[email protected]"
]
}
}
201
{
"id": 11,
"subject": "You are the super online contest winner !!!",
"created_at": "2017-11-22T13:43:44.207Z",
"updated_at": "2017-11-22T13:43:44.207Z",
"identifier": "an_unique_identifier",
"meta": {},
"title": "You won the big jackpot",
"subtitle": "And it's kinda awesome",
"attachment": null,
"from": "[email protected]",
"to": [
"[email protected]"
],
"cc": null,
"bcc": null,
"content": "Hi andre,\nYou just *won* the mego jackpot !\nCheck [this link](http://spam.prizepool-game-lottery.xxx/winner.php)",
"html_content": "<p>Hi andre,\nYou just <em>won</em> the mego jackpot !\nCheck <a href=\"http://spam.prizepool-game-lottery.xxx/winner.php\">this link</a></p>\n",
"attachments": null
}
curl -X POST -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"mailing":{"content":"Hi andre,\nYou just *won* the mego jackpot !\nCheck [this link](http://spam.prizepool-game-lottery.xxx/winner.php)","from":"[email protected]","identifier":"an_unique_identifier","subject":"You are the super online contest winner !!!","subtitle":"And it's kinda awesome","title":"You won the big jackpot","to":["[email protected]"]}}' "https://api.intra.42.fr/v2/mailings"
{
"id": 11,
"subject": "You are the super online contest winner !!!",
"created_at": "2017-11-22T13:43:44.207Z",
"updated_at": "2017-11-22T13:43:44.207Z",
"identifier": "an_unique_identifier",
"meta": {},
"title": "You won the big jackpot",
"subtitle": "And it's kinda awesome",
"attachment": null,
"from": "[email protected]",
"to": [
"[email protected]"
],
"cc": null,
"bcc": null,
"content": "Hi andre,\nYou just *won* the mego jackpot !\nCheck [this link](http://spam.prizepool-game-lottery.xxx/winner.php)",
"html_content": "<p>Hi andre,\nYou just <em>won</em> the mego jackpot !\nCheck <a href=\"http://spam.prizepool-game-lottery.xxx/winner.php\">this link</a></p>\n",
"attachments": null
}
require "oauth2"
UID = "Your application uid"
SECRET = "Your application secret"
client = OAuth2::Client.new(UID, SECRET, site: "https://api.intra.42.fr")
token = client.client_credentials.get_token
params = {mailing: {content: "Hi andre,
You just *won* the mego jackpot !
Check [this link](http://spam.prizepool-game-lottery.xxx/winner.php)", from: "[email protected]", identifier: "an_unique_identifier", subject: "You are the super online contest winner !!!", subtitle: "And it's kinda awesome", title: "You won the big jackpot", to: ["[email protected]"]}}
response = token.post("/v2/mailings", params: params)
response.status
# => 201
response.parsed
# => {"id"=>11, "subject"=>"You are the super online contest winner !!!", "created_at"=>"2017-11-22T13:43:44.207Z", "updated_at"=>"2017-11-22T13:43:44.207Z", "identifier"=>"an_unique_identifier", "meta"=>{}, "title"=>"You won the big jackpot", "subtitle"=>"And it's kinda awesome", "attachment"=>nil, "from"=>"[email protected]", "to"=>["[email protected]"], "cc"=>nil, "bcc"=>nil, "content"=>"Hi andre,\nYou just *won* the mego jackpot !\nCheck [this link](http://spam.prizepool-game-lottery.xxx/winner.php)", "html_content"=>"<p>Hi andre,\nYou just <em>won</em> the mego jackpot !\nCheck <a href=\"http://spam.prizepool-game-lottery.xxx/winner.php\">this link</a></p>\n", "attachments"=>nil}