Commit 608b7349 authored by Martin van Es's avatar Martin van Es
Browse files

Improve admin phpmailer.php config

parent d83b5251
......@@ -3,3 +3,4 @@ cert/*
!cert/KEEP
database/data/*
!database/data/KEEP
testidp/phpmailer.php
......@@ -11,7 +11,7 @@ wildcard_cert.key
```testidp/config/logins.json``` contains all the testaccounts and is volume mounted.
```testidp/admin/application/classes/phpmailer.php``` contains the phpmailer configuration for sending the admin mails. You should replace the Username/Password, Host and setFrom. It is also volume mounted.
```testidp/phpmailer.php.example``` contains the phpmailer example configuration for sending the admin mails. You should copy it to ```testidp/phpmailer.php``` and replace the Username/Password, Host and setFrom.
When everything is in place a simple
```
......
......@@ -32,6 +32,7 @@ RUN ln -s /opt/simplesamlphp-1.19.1 /opt/simplesamlphp
COPY ssphp_config.php.in /tmp
COPY admin_config.php.in /tmp
COPY phpmailer.php /opt/admin/application/classes/phpmailer.php
COPY apache/testidp.conf.in /tmp
COPY cert/ /etc/apache2/cert
COPY simplesamlphp/ /opt/simplesamlphp
......
......@@ -14,36 +14,20 @@ class custom_phpmailer {
$mail->CharSet = "UTF-8";
$mail->isSMTP();
$mail->SMTPDebug = 0; // 0 = off (for production use) - 1 = client messages - 2 = client and server messages
//$mail->Host = "smtp.gmail.com"; // use $mail->Host = gethostbyname('smtp.gmail.com'); // if your network does not support SMTP over IPv6
$mail->Host = "in-v3.mailjet.com";
$mail->Host = gethostbyname('replace your.mailrelay.org');
//$mail->Port = 465; // TLS only
$mail->Port = 587; // TLS only
//$mail->SMTPSecure = 'ssl'; // ssl is deprecated
$mail->SMTPAuth = true;
//$mail->Username = 'geant.incubator@gmail.com';
$mail->Username = 'eaa84e1afc080e61cdf87e021b2b3f8e';
//$mail->Password = '=xtJEq&>+]TS&qu7-719}B{E[4';
$mail->Password = 'f444618af6955a1aba1c29f219fe6746';
//$mail->setFrom('noreply@testidp.incubator.geant.org', 'Test IDP portal');
$mail->setFrom('tikrasseo@gmail.com', 'Test IDP portal');
$mail->Username = 'replace username';
$mail->Password = 'replace password';
$mail->setFrom('example.org', 'Test IDP portal');
if (security::check_request_data($to_name)) {
$mail->addAddress($to, $to_name);
} else {
$mail->addAddress($to);
}
$mail->Subject = $subject;
/*
$from_ip = '';
if(filter_var('', FILTER_VALIDATE_IP)) {
$from_ip = @$_SERVER['HTTP_CLIENT_IP'];
} elseif(filter_var('', FILTER_VALIDATE_IP)) {
$from_ip = @$_SERVER['HTTP_X_FORWARDED_FOR'];
} else {
$from_ip = @$_SERVER['REMOTE_ADDR'];
}
$message .= '<br />Sent from IP: '.$from_ip;
*/
$mail->msgHTML($message); //$mail->msgHTML(file_get_contents('contents.html'), __DIR__); //Read an HTML message body from an external file, convert referenced images to embedded,
$mail->msgHTML($message); embedded,
$mail->AltBody = strip_tags(str_replace('<br />', "\n\r", $message));
if(!$mail->send()){
return security::format_message("ERROR:Įvyko klaida siunčiant el. laišką. Prašome kreiptis į administratorių.");
......
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once(APP_BASE_DIR.'/classes/phpmailer/Exception.php');
require_once(APP_BASE_DIR.'/classes/phpmailer/PHPMailer.php');
require_once(APP_BASE_DIR.'/classes/phpmailer/SMTP.php');
class custom_phpmailer {
public function __construct() {
}
public static function send_email($to, $to_name='', $subject='Message from Test IDP portal', $message, $success='Your account registration is pending') {
$mail = new PHPMailer;
$mail->CharSet = "UTF-8";
$mail->isSMTP();
$mail->SMTPDebug = 0; // 0 = off (for production use) - 1 = client messages - 2 = client and server messages
$mail->Host = gethostbyname('replace your.mailrelay.org');
//$mail->Port = 465; // TLS only
$mail->Port = 587; // TLS only
$mail->SMTPAuth = true;
$mail->Username = 'replace username';
$mail->Password = 'replace password';
$mail->setFrom('example.org', 'Test IDP portal');
if (security::check_request_data($to_name)) {
$mail->addAddress($to, $to_name);
} else {
$mail->addAddress($to);
}
$mail->Subject = $subject;
$mail->msgHTML($message); embedded,
$mail->AltBody = strip_tags(str_replace('<br />', "\n\r", $message));
if(!$mail->send()){
return security::format_message("ERROR:Įvyko klaida siunčiant el. laišką. Prašome kreiptis į administratorių.");
} else {
return $success;
}
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment