This commit is contained in:
Bozhidar 2024-09-25 14:45:04 +03:00
parent 29493603b4
commit 9718506b3b
5 changed files with 32 additions and 12 deletions

View file

@ -55,6 +55,10 @@ class SetupEmailServer extends Command
'database' => PhyreConfig::get('DB_DATABASE'),
];
if (!is_dir('/etc/postfix/sql')) {
mkdir('/etc/postfix/sql');
}
$postfixMysqlVirtualAliasMapsCf = PhyreBlade::render('email::server.postfix.sql.mysql_virtual_alias_maps.cf',$mysqlDbDetails);
file_put_contents('/etc/postfix/sql/mysql_virtual_alias_maps.cf', $postfixMysqlVirtualAliasMapsCf);

View file

@ -19,6 +19,13 @@ class EmailSettings extends BaseSettings
protected static ?int $navigationSort = 4;
public function save() : void
{
parent::save();
\Artisan::call('email:setup-email-server');
}
public function schema(): array
{

View file

@ -29,9 +29,14 @@ Welcome to your new account.
';
public $subject = 'Welcome';
public function getEmailDomain()
{
return setting('email.domain');
}
public function form(Form $form): Form
{
$this->from = 'admin@';
$this->from = 'admin@'.$this->getEmailDomain();
return $form
->schema([
@ -57,9 +62,11 @@ Welcome to your new account.
public function send()
{
$emailDomain = $this->getEmailDomain();
$phpMailer = new PHPMailer();
$phpMailer->isMail();
$phpMailer->setFrom('admin@allsidepixels.com', 'admin@allsidepixels.com');
$phpMailer->setFrom('admin@' . $emailDomain, 'admin@'.$emailDomain);
$phpMailer->addAddress($this->to);
$phpMailer->Subject = $this->subject;
$phpMailer->Body = $this->body;

View file

@ -34,9 +34,10 @@ class EmailBoxResource extends Resource
Forms\Components\TextInput::make('username')
->label('Username')
->disabled(function ($record) {
if ($record) {
return $record->exists;
})
->columnSpanFull(),
}
})->columnSpanFull(),
Forms\Components\Select::make('domain')
->label('Domain')

View file

@ -1,11 +1,12 @@
sudo apt-get update -y
sudo apt-get install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved -y
sudo apt-get install postfix postfix-mysql -y
sudo apt-get install mailutils -y
sudo apt-get install opendkim opendkim-tools -y
sudo apt-get install spamassassin spamc -y
sudo apt-get install clamav clamav-daemon -y
sudo apt-get install amavisd-new -y
sudo DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install dovecot-core dovecot-imapd dovecot-pop3d dovecot-lmtpd dovecot-mysql dovecot-sieve dovecot-managesieved -yq
sudo DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends install postfix postfix-mysql -yq
sudo apt-get --no-install-recommends install mailutils -yq
sudo apt-get --no-install-recommends install opendkim opendkim-tools -yq
sudo apt-get --no-install-recommends install spamassassin spamc -yq
sudo apt-get --no-install-recommends install clamav clamav-daemon -yq
sudo apt-get --no-install-recommends install amavisd-new -yq
# Enable email ports
ufw allow 25