An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
<?php
use Illuminate\Mail\Message;
use Symfony\Component\Mime\Address;
use Symfony\Component\Mime\Email;
it('uses the configured transactional from name and address', function () {
$identity = mail_from_identity((object) [
'smtp_from_address' => '[email protected]',
'smtp_from_name' => 'Coolify',
]);
expect($identity['address'])->toBe('[email protected]')
->and($identity['name'])->toBe('Coolify');
});
it('does not fall back to the email local part when a from name is set', function () {
$address = mail_from_address((object) [
'smtp_from_address' => '[email protected]',
'smtp_from_name' => 'Coolify',
]);
expect($address)->toBeInstanceOf(Address::class)
->and($address->getAddress())->toBe('[email protected]')
->and($address->getName())->toBe('Coolify')
->and($address->getName())->not->toBe('admin');
});
it('formats the transactional sender for resend', function () {
$formattedAddress = mail_from_formatted((object) [
'smtp_from_address' => '[email protected]',
'smtp_from_name' => 'Coolify',
]);
expect($formattedAddress)->toBe('"Coolify" <[email protected]>');
});
it('keeps the smtp from name and address on the same header line', function () {
$email = mail_from_email(new Email, (object) [
'smtp_host' => 'smtp.protonmail.ch',
'smtp_from_address' => '[email protected]',
'smtp_from_name' => 'Advanced Digital Marketing LTDA',
]);
expect($email->getHeaders()->get('From')?->toString())
->toBe('From: Advanced Digital Marketing LTDA <[email protected]>');
});
it('keeps the Laravel mail from name and address on the same header line', function () {
$message = mail_from_message(new Message(new Email), (object) [
'smtp_host' => 'smtp.protonmail.ch',
'smtp_from_address' => '[email protected]',
'smtp_from_name' => 'Advanced Digital Marketing LTDA',
]);
expect($message->getSymfonyMessage()->getHeaders()->get('From')?->toString())
->toBe('From: Advanced Digital Marketing LTDA <[email protected]>');
});
it('keeps Symfony header folding for other smtp providers', function () {
$email = mail_from_email(new Email, (object) [
'smtp_host' => 'smtp.example.com',
'smtp_from_address' => '[email protected]',
'smtp_from_name' => 'Advanced Digital Marketing LTDA',
]);
expect($email->getHeaders()->get('From')?->toString())
->toBe("From: Advanced Digital Marketing LTDA\r\n <[email protected]>");
});
it('treats a blank from name as missing instead of sending an unnamed address', function () {
$identity = mail_from_identity((object) [
'smtp_from_address' => '[email protected]',
'smtp_from_name' => ' ',
]);
expect($identity['name'])->toBe('Coolify')
->and($identity['name'])->not->toBe('admin');
});
it('rejects enabled email settings without a from address', function () {
mail_from_identity((object) [
'smtp_enabled' => true,
'smtp_from_address' => null,
'smtp_from_name' => 'Coolify',
]);
})->throws(InvalidArgumentException::class, 'Transactional email sender address is not configured.');