Skip to content

Open a New Mail Window in the EVE Client

Leon Jacobs edited this page Jan 17, 2017 · 6 revisions

SeAT

Open a New Mail Window in the EVE Client

This article aims to show you how to structure your Eseye call to achieve this!

the swagger definition

On the EVE Swagger Interface, the endpoint to open a prepared email in the EVE Client is defined here: https://esi.tech.ccp.is/latest/#!/User_Interface/post_ui_openwindow_newmail. The endpoint itself is described as a POST method to /ui/openwindow/newmail/ with the following json payload being accepted:

{
  "body": "string",
  "recipients": [
    0
  ],
  "subject": "string",
  "to_corp_or_alliance_id": 0,
  "to_mailing_list_id": 0
}

Nice and easy really. In the case of the Eseye library, the only thing that might be tricky is getting the array properly formatted in the setBody() method. Lets take a look at an example.

the newmail body

In the case of the example, I only want to send this eve mail to myself with a body and a subject so I am only going to be setting those keys. You can ofc set all the others too if you want. So, the json version of the keys I am going to be setting is:

{
  "body": "string",
  "recipients": [
    0
  ],
  "subject": "string"
}

In PHP, well, this array is very similar. The payload I want to send will therefore be:

[
    'body' => 'This is the body that I want in the EVE Mail',
    'recipients' => [
        1477919642
    ],
    'subject' => 'ESI initiated EVE Mail :D'
]

the eseye call

We now know what the payload should look like; lets convert that into something Eseye will handle for us!

$esi->setBody([
    'body' => 'This is the body that I want in the EVE Mail',
    'recipients' => [
        1477919642
    ],
    'subject' => 'ESI initiated EVE Mail :D'
])->invoke('post', '/ui/openwindow/newmail/');

Thats it! As the call gets invoked, you should see a new evemail window pop up in your client with the content you specified ;)

evemail

full script example:

The above example in a full scripted context:

<?php

// Eseye - Simple Email Preparation Example

include 'vendor/autoload.php';

$esi = new \Seat\Eseye\Eseye(new \Seat\Eseye\Containers\EsiAuthentication([
    'client_id'     => 'client_id_string',
    'secret'        => 'secret_key_string',
    'refresh_token' => 'refresh_token_string',
]));

$esi->setBody([
    'body' => 'This is the body that I want in the EVE Mail',
    'recipients' => [
        1477919642
    ],
    'subject' => 'ESI initiated EVE Mail :D'
])->invoke('post', '/ui/openwindow/newmail/');