Create a new, authenticated mail, from 42.

live_help Notes

assignment This action requires one of theses roles: Advanced tutor, Avanced staff
call_split This action is performed asynchronously, which implies that the result of the action isn't included in the response.

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 sender <sender@email> format. If none, set from no-reply@42.fr

mailing[to] optional , nil allowed . Must be an array of any type

An array of emails for the mail’s to field

mailing[cc] optional , nil allowed . Must be an array of any type

An array of emails for the mail’s cc field

mailing[bcc] optional , nil allowed . Must be an array of any type

An array of emails for the mail’s bcc field

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.

comments powered by <span class='logo-disqus'>Disqus</span>
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": "superwin-ultimate-@prizepool-game-lottery.sexy",
    "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": [
      "andre@42.fr"
    ]
  }
}
201
{
  "id": 14,
  "subject": "You are the super online contest winner !!!",
  "created_at": "2017-03-06T15:20:19.047Z",
  "updated_at": "2017-03-06T15:20:19.047Z",
  "identifier": "an_unique_identifier",
  "meta": {},
  "title": "You won the big jackpot",
  "subtitle": "And it's kinda awesome",
  "attachment": null,
  "from": "superwin-ultimate-@prizepool-game-lottery.sexy",
  "to": [
    "andre@42.fr"
  ],
  "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":"superwin-ultimate-@prizepool-game-lottery.sexy","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":["andre@42.fr"]}}' "https://api.intra.42.fr/v2/mailings"

{
  "id": 14,
  "subject": "You are the super online contest winner !!!",
  "created_at": "2017-03-06T15:20:19.047Z",
  "updated_at": "2017-03-06T15:20:19.047Z",
  "identifier": "an_unique_identifier",
  "meta": {},
  "title": "You won the big jackpot",
  "subtitle": "And it's kinda awesome",
  "attachment": null,
  "from": "superwin-ultimate-@prizepool-game-lottery.sexy",
  "to": [
    "andre@42.fr"
  ],
  "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: "superwin-ultimate-@prizepool-game-lottery.sexy", 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: ["andre@42.fr"]}}
response = token.post("/v2/mailings", params: params)
response.status
# => 201
response.parsed
# => {"id"=>14, "subject"=>"You are the super online contest winner !!!", "created_at"=>"2017-03-06T15:20:19.047Z", "updated_at"=>"2017-03-06T15:20:19.047Z", "identifier"=>"an_unique_identifier", "meta"=>{}, "title"=>"You won the big jackpot", "subtitle"=>"And it's kinda awesome", "attachment"=>nil, "from"=>"superwin-ultimate-@prizepool-game-lottery.sexy", "to"=>["andre@42.fr"], "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}