You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying to use Haraka as the Mail Server in our new project ,We are trying to make our own plugin and no way we could find a solution to access the mail properties like Body and the attachments , Can any one please help us to find an existing plugin which we could get the mail properties like , Receivers, Body , Attachment etc.. Or the sample code snippet that can be used to access this properties
Below is a sample code which we are writing our plugin
varutil=require('util');exports.register=function(){this.logdebug("Initializing Parse Message Plugin ....");this.register_hook('attachment','process_attachments');};exports.hook_data=function(next,connection){this.logdebug("inside hook_data ....");// Enable mail body parsing - should be enabled in hook_dataconnection.transaction.parse_body=true;next();}exports.hook_data_post=function(next,connection){this.logdebug("inside hook_data_post ....");consttransaction=connection.transaction;this.logdebug('length is ',transaction.body.children?.length);// Extract text and attachments from the email partsif(transaction.body.children?.length){for(constpartoftransaction.body.children){//this.logdebug('part is', util.inspect(part));if(part.ct==='text/plain'){// This part is the plain text bodythis.loginfo('Body text:',part.bodytext);}elseif(part.ct.includes('application/octet-stream')){// This part is the attachmentconstattachment={filename: part.ct,content: part.body_text_encoded,// or part.body, depending on how it's storedcontentType: part.ct};this.process_attachments(connection,[attachment]);}}}next();}exports.process_attachments=function(connection,attachments){for(constattachmentofattachments){this.loginfo(`Received attachment: ${attachment.filename}, Size: ${attachment.content.length}`);// Process the attachment here}}exports.hook_queue=function(next,connection){this.logdebug("inside hook_queue ....");// Enable mail body parsing - should be enabled in hook_dataconnection.transaction.parse_body=true;// get a decoded copy of a header, e.g. Fromvarfrom_header=connection.transaction.header.get_decoded('From');this.loginfo('from is',from_header);// get a header that doesn't need to be decoded:varmsg_id=connection.transaction.header.get('Message-ID');this.loginfo('msg_id is',msg_id);// get multiple headers, e.g. Received:varreceived=connection.transaction.rcpt_to;this.loginfo('received is',received);next();}exports.shutdown=function(){this.loginfo("Shutting Parse Message Plugin.");};
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Trying to use Haraka as the Mail Server in our new project ,We are trying to make our own plugin and no way we could find a solution to access the mail properties like Body and the attachments , Can any one please help us to find an existing plugin which we could get the mail properties like , Receivers, Body , Attachment etc.. Or the sample code snippet that can be used to access this properties
Below is a sample code which we are writing our plugin
Beta Was this translation helpful? Give feedback.
All reactions