Compare commits
2 commits
3b643ccd64
...
99d94eb54d
Author | SHA1 | Date | |
---|---|---|---|
Simon Vieille | 99d94eb54d | ||
Simon Vieille | 961034266b |
2
DOCS.md
2
DOCS.md
|
@ -28,7 +28,7 @@ url: https://gitnet.fr/deblan/woodpecker-email
|
||||||
```
|
```
|
||||||
steps:
|
steps:
|
||||||
mail:
|
mail:
|
||||||
image: deblan/woodpecker-email-php
|
image: deblan/woodpecker-email
|
||||||
settings:
|
settings:
|
||||||
dsn: "smtp://username:password@mail.example.com:587?verify_peer=1"
|
dsn: "smtp://username:password@mail.example.com:587?verify_peer=1"
|
||||||
from:
|
from:
|
||||||
|
|
27
bin/console
27
bin/console
|
@ -103,13 +103,23 @@ function writeln(...$values)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleError($section, Exception $e)
|
function handleError($section, Exception $e, bool $debug)
|
||||||
{
|
{
|
||||||
writeln(
|
writeln(
|
||||||
sprintf('ERROR - %s', $section),
|
sprintf('ERROR - %s', $section),
|
||||||
$e->getMessage()
|
$e->getMessage()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ($debug) {
|
||||||
|
writeln(
|
||||||
|
"",
|
||||||
|
"Trace",
|
||||||
|
"=====",
|
||||||
|
json_encode($e->getTrace(), JSON_PRETTY_PRINT),
|
||||||
|
"=====",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,11 +127,8 @@ if ($config['is_debug']) {
|
||||||
writeln(
|
writeln(
|
||||||
'Debug',
|
'Debug',
|
||||||
'=====',
|
'=====',
|
||||||
'Config',
|
json_encode(['config' => $config, 'environment' => $_SERVER], JSON_PRETTY_PRINT),
|
||||||
json_encode($config, JSON_PRETTY_PRINT),
|
'=====',
|
||||||
'Environment',
|
|
||||||
json_encode($_SERVER, JSON_PRETTY_PRINT),
|
|
||||||
'====='
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,11 +148,11 @@ try {
|
||||||
writeln('Email sent!');
|
writeln('Email sent!');
|
||||||
}
|
}
|
||||||
} catch (SyntaxError $e) {
|
} catch (SyntaxError $e) {
|
||||||
handleError('Syntax error', $e);
|
handleError('Syntax error', $e, $config['is_debug']);
|
||||||
} catch (TransportException $e) {
|
} catch (TransportException $e) {
|
||||||
handleError('Transport error', $e);
|
handleError('Transport error', $e, $config['is_debug']);
|
||||||
} catch (RfcComplianceException $e) {
|
} catch (RfcComplianceException $e) {
|
||||||
handleError('RFC compliance error', $e);
|
handleError('RFC compliance error', $e, $config['is_debug']);
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
handleError('Generic error', $e);
|
handleError('Generic error', $e, $config['is_debug']);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ class EmailFactory
|
||||||
|
|
||||||
public function createMailer(): Mailer
|
public function createMailer(): Mailer
|
||||||
{
|
{
|
||||||
return new Mailer(Transport::fromDsn($this->config['dsn']));
|
return new Mailer(Transport::fromDsn((string) $this->config['dsn']));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createEmail(): Email
|
public function createEmail(): Email
|
||||||
|
|
Loading…
Reference in a new issue