Browse Source

Merge branch 'dev/add_custom_tls_cert' of Neraud/ttrss-mailer-smtp into master

fox 7 months ago
parent
commit
eebc18f00e
2 changed files with 11 additions and 1 deletions
  1. 4 0
      README.md
  2. 7 1
      init.php

+ 4 - 0
README.md

@@ -25,6 +25,10 @@ per-user).
 
 	define('SMTP_SKIP_CERT_CHECKS', false);
 	// Accept all SSL certificates, use with caution.
+
+	define('SMTP_CA_FILE', '/path/to/ca.crt');
+	// Use a custom CA certificate for SSL/TLS secure connections.
+	// Only used if SMTP_SKIP_CERT_CHECKS is false.
 ```
 
 At least SMTP_SERVER needs to set for plugin to work.

+ 7 - 1
init.php

@@ -50,7 +50,13 @@ class mailer_smtp extends Plugin {
 				        'allow_self_signed' => true
 				    )
 				);
-			}
+			} elseif (defined('SMTP_CA_FILE') && SMTP_CA_FILE) {
+				$phpmailer->SMTPOptions = array(
+				    'ssl' => array(
+                        'cafile' => SMTP_CA_FILE
+				    )
+				);
+            }
 
 			$from_name = $params["from_name"] ? $params["from_name"] : SMTP_FROM_NAME;
 			$from_address = $params["from_address"] ? $params["from_address"] : SMTP_FROM_ADDRESS;