From 6eb228d0b8677fe2246ff013c8822bf25915617c Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Fri, 31 May 2024 12:59:23 +0100 Subject: [PATCH] chore: Add INCOMING_EMAIL_DOMAIN to host_list configuration This code change adds the INCOMING_EMAIL_DOMAIN variable to the host_list configuration in the Haraka init.sh script. This ensures that incoming emails from the specified domain are accepted by the Haraka application. The INCOMING_EMAIL_DOMAIN value is appended to the host_list file, allowing the application to properly handle emails from this domain. --- Haraka/config/{host_list.ini => host_list} | 0 Haraka/init.sh | 4 +-- Haraka/plugins/email_parser.js | 41 +++++++++++++--------- 3 files changed, 25 insertions(+), 20 deletions(-) rename Haraka/config/{host_list.ini => host_list} (100%) diff --git a/Haraka/config/host_list.ini b/Haraka/config/host_list similarity index 100% rename from Haraka/config/host_list.ini rename to Haraka/config/host_list diff --git a/Haraka/init.sh b/Haraka/init.sh index 5e4a8c47b7..f539df420a 100644 --- a/Haraka/init.sh +++ b/Haraka/init.sh @@ -3,6 +3,7 @@ # Setup auth echo "domain = $DOMAIN" >> /harakaapp/config/dkim_sign.ini echo "$DOMAIN" > /harakaapp/config/host_list +echo "$INCOMING_EMAIL_DOMAIN" >> /harakaapp/config/host_list echo "$DOMAIN" > /harakaapp/config/me echo "$SMTP_EMAIL=$SMTP_PASSWORD" >> /harakaapp/config/auth_flat_file.ini @@ -23,9 +24,6 @@ echo "Type: TXT" echo "Key: $DKIM_SELECTOR._domainkey" echo "v=DKIM1;p=$(grep -v '^-' /harakaapp/config/dkim/$DOMAIN/public | tr -d '\n')" -# Add Hosts -echo $DOMAIN >> /harakaapp/config/host_list.ini -echo $INCOMING_EMAIL_DOMAIN >> /harakaapp/config/host_list.ini # Run haraka haraka -c /harakaapp \ No newline at end of file diff --git a/Haraka/plugins/email_parser.js b/Haraka/plugins/email_parser.js index 67b2a62e6d..2bea75127a 100644 --- a/Haraka/plugins/email_parser.js +++ b/Haraka/plugins/email_parser.js @@ -1,23 +1,30 @@ -const MailParser = require('mailparser').MailParser; +// const MailParser = require('mailparser').MailParser; -exports.hook_data_post = function (next, connection) { - // Get the email data - var email_data = connection.transaction.data_lines.join('\n'); +// exports.hook_data_post = function (next, connection) { +// // Get the email data +// var email_data = connection.transaction.data_lines.join('\n'); - // Parse the email data - var mailparser = new MailParser(); +// // Parse the email data +// var mailparser = new MailParser(); - mailparser.on('end', function(mail_object){ - // Log the email data - connection.loginfo('Subject: ' + mail_object.subject); - connection.loginfo('From: ' + JSON.stringify(mail_object.from)); - connection.loginfo('To: ' + JSON.stringify(mail_object.to)); - connection.loginfo('Text: ' + mail_object.text); - connection.loginfo('HTML: ' + mail_object.html); - }); +// mailparser.on('end', function(mail_object){ +// // Log the email data +// connection.loginfo('Subject: ' + mail_object.subject); +// connection.loginfo('From: ' + JSON.stringify(mail_object.from)); +// connection.loginfo('To: ' + JSON.stringify(mail_object.to)); +// connection.loginfo('Text: ' + mail_object.text); +// connection.loginfo('HTML: ' + mail_object.html); +// }); - mailparser.write(email_data); - mailparser.end(); +// mailparser.write(email_data); +// mailparser.end(); +// next(); +// }; + + +exports.hook_rcpt = function (next, connection, params) { + var rcpt = params[0]; + this.loginfo("Got recipient: " + rcpt); next(); -}; +} \ No newline at end of file