mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 09:37:26 +00:00
51 lines
1.4 KiB
PHP
51 lines
1.4 KiB
PHP
<?php
|
|
|
|
class Mailgun
|
|
{
|
|
public const BASE_URL = 'https://api.mailgun.net/v3';
|
|
|
|
public const TOP_DOMAIN = 'lbry.com';
|
|
public const MAIL_DOMAIN = 'mail.lbry.com';
|
|
|
|
public const LIST_GENERAL = 'lbryians@lbry.com';
|
|
|
|
public static function sendDmcaReport($data)
|
|
{
|
|
list($status, $headers, $body) = static::post('/' . static::MAIL_DOMAIN . '/messages', [
|
|
'from' => 'LBRY <mail@' . static::MAIL_DOMAIN . '>',
|
|
'to' => 'hello@lbry.com',
|
|
'subject' => 'DMCA Report #' . $data['report_id'],
|
|
'html' => '<pre>' . var_export($data, true) . '</pre>',
|
|
'o:tracking-clicks' => 'no',
|
|
'o:tracking-opens' => 'no'
|
|
]);
|
|
|
|
return $status == 200;
|
|
}
|
|
|
|
protected static function post($endpoint, $data)
|
|
{
|
|
return static::request(Curl::POST, $endpoint, $data);
|
|
}
|
|
|
|
protected static function put($endpoint, $data)
|
|
{
|
|
return static::request(Curl::PUT, $endpoint, $data);
|
|
}
|
|
|
|
protected static function request($method, $endpoint, $data)
|
|
{
|
|
return Curl::doCurl($method, self::BASE_URL . $endpoint, $data, [
|
|
'headers' => [
|
|
'Authorization: Basic ' . base64_encode('api:' . Config::get(Config::MAILGUN_API_KEY))
|
|
],
|
|
'retry' => 3,
|
|
]);
|
|
}
|
|
|
|
protected static function inlineCss($html, $css = '')
|
|
{
|
|
$e = new \Pelago\Emogrifier($html, $css);
|
|
return trim($e->emogrify());
|
|
}
|
|
}
|