Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Env vars for SMTP Configuration. #1182

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions includes/Classes/Emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -1074,13 +1074,13 @@ public function send($arguments)
};
}

switch (get_option('mail_system_use')) {
switch ($_ENV['MAIL_SYSTEM_USE'] ?? get_option('mail_system_use')) {
case 'smtp':
$email->IsSMTP();
$email->Host = get_option('mail_smtp_host');
$email->Port = get_option('mail_smtp_port');
$email->Username = get_option('mail_smtp_user');
$email->Password = get_option('mail_smtp_pass');
$email->Host = $_ENV['MAIL_SMTP_HOST'] ?? get_option('mail_smtp_host');
$email->Port = $_ENV['MAIL_SMTP_PORT'] ?? get_option('mail_smtp_port');
$email->Username = $_ENV['MAIL_SMTP_USER'] ?? get_option('mail_smtp_user');
$email->Password = $_ENV['MAIL_SMTP_PASS'] ?? get_option('mail_smtp_pass');

if (get_option('mail_smtp_auth') != 'none') {
$email->SMTPAuth = true;
Expand Down
8 changes: 7 additions & 1 deletion includes/forms/options/email.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
<div class="form-group row">
<label for="mail_system_use" class="col-sm-4 control-label"><?php _e('Mailer','cftp_admin'); ?></label>
<div class="col-sm-8">
<?php if ($_ENV['MAIL_SYSTEM_USE'] || $_ENV['MAIL_SMTP_HOST'])
echo '
<div class="alert alert-warning" role="alert">
Settings overwritten by enviroment variables.
</div>';
?>
<select class="form-select" name="mail_system_use" id="mail_system_use" required>
<option value="mail" <?php echo (get_option('mail_system_use') == 'mail') ? 'selected="selected"' : ''; ?>>PHP Mail (basic)</option>
<option value="smtp" <?php echo (get_option('mail_system_use') == 'smtp') ? 'selected="selected"' : ''; ?>>SMTP</option>
Expand Down Expand Up @@ -198,4 +204,4 @@
<a href="email-test.php">
<?php _e('After saving your options, you can test your configuration here', 'cftp_admin'); ?>
</a>
</p>
</p>