diff --git a/.gitignore b/.gitignore index 1a81200fd1e0bad0d6b60ba371b48cdfcc475bf1..c7fdf738767f749883ed777eb894bbbe3497cbf8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ cert/* !cert/KEEP database/data/* !database/data/KEEP +testidp/phpmailer.php diff --git a/README.md b/README.md index b4f89565492f65cd29fc39ad44a8472259d5310b..ee0a8c57969173936a380dac444af8799433445a 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/testidp/Dockerfile b/testidp/Dockerfile index b725f77274ba4e3c9264e2176a7b9b184414151a..1db7a88b32738e8b5f74f8a4dd3dcf7f203b464f 100644 --- a/testidp/Dockerfile +++ b/testidp/Dockerfile @@ -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 diff --git a/testidp/admin/application/classes/phpmailer.php b/testidp/admin/application/classes/phpmailer.php index 0f65df5ac3008804947f259b4f400b36f2c3c743..2a6fdd058d5325027eae5a0d02b5c7eff4d7a627 100644 --- a/testidp/admin/application/classes/phpmailer.php +++ b/testidp/admin/application/classes/phpmailer.php @@ -8,48 +8,32 @@ 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->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ų."); } else { return $success; - } + } } } ?> diff --git a/testidp/phpmailer.php.example b/testidp/phpmailer.php.example new file mode 100644 index 0000000000000000000000000000000000000000..2a6fdd058d5325027eae5a0d02b5c7eff4d7a627 --- /dev/null +++ b/testidp/phpmailer.php.example @@ -0,0 +1,39 @@ +<?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; + } + } +} +?>