-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5d862f3
commit 8205f03
Showing
2 changed files
with
46 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,15 +18,18 @@ | |
* Makes it easy to edit the username, password, port, etc. | ||
* LOAD from a env file that's in the root folder, the template can be found in | ||
* .env.example file | ||
* | ||
* Original: $dotenv = Dotenv\Dotenv::createImmutable(__DIR__); | ||
* Changed to put in private folder outside www | ||
*/ | ||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); | ||
$dotenv = Dotenv\Dotenv::createImmutable('/home/codidact/private/'); | ||
$dotenv->load(); | ||
$constants = array( | ||
"HOST" => $_ENV['HOST'], | ||
"USERNAME" => $_ENV['USERNAME'], | ||
"PASSWORD" => $_ENV['PASSWORD'], | ||
"PORT" => (int)$_ENV['PORT'], | ||
"FROM" => $_ENV['FROM'], | ||
"TO" => $_ENV['TO'], | ||
"DEBUG" => (int)$_ENV['DEBUG'] | ||
); | ||
|
||
|
@@ -53,14 +56,12 @@ | |
* Server settings. | ||
*/ | ||
$mail->SMTPDebug = $constants["DEBUG"]; | ||
$mail->isSMTP(); | ||
$mail->Host = $constants["HOST"]; | ||
$mail->SMTPAuth = true; | ||
$mail->Username = $constants["USERNAME"]; | ||
$mail->Password = $constants["PASSWORD"]; | ||
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; | ||
$mail->Port = $constants["PORT"]; | ||
$mail->SMTPSecure = 'ssl'; | ||
/* | ||
* Should be turned on in production. | ||
* $mail->SMTPDebug = false; | ||
|
@@ -69,23 +70,22 @@ | |
/* | ||
* Email recipents. | ||
*/ | ||
$mail->setFrom($constants["FROM"]); | ||
$mail->addAddress($emailString); | ||
$mail->setFrom($emailString); | ||
$mail->addAddress($constants["TO"]); | ||
/* | ||
Content section. Subject and body goes here. | ||
*/ | ||
$mail->Subject = ''; | ||
$mail->Body = ''; | ||
$mail->Subject = 'Subscription to Codidact email list'; | ||
$mail->Body = 'Subscription request for [email protected]'; | ||
$mail->AltBody = ''; | ||
/* | ||
Send the mail. | ||
*/ | ||
$mail->send(); | ||
$responseString = "Subscribed!"; | ||
$responseString = "Thank you for your subscription request. You should receive an automated message with confirmation instructions.<br><a href=\"https://codidact.org\">Click here to return to Codidact</a>"; | ||
echo $responseString; | ||
} catch (Exception $e) { | ||
$err = $mail->ErrorInfo; | ||
$responseString = "Mail was not sent, please report the issue <a href='https://github.com/codidact/landing-page/issues'>here</a>"; | ||
echo $responseString; | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.