Closed adamramadhan closed 12 years ago
in config/loglevel change the entry to LOGPROTOCOL and re-run your test; then post the full log output; it will be obvious where this is failing then.
I can see why you're getting two messages (you're sending a message in hook_data_post whilst the message that is coming in will be sent by hook_queue_outbound) but not why you're getting the error message.
If it's dieing - then there should be a stack trace in the log as well.
where should i put the message.send() ?
I'm not really sure what you are trying to achieve here to be honest. You don't need to generate a message at all if you simply just want to reject messages that contain attachments.
If you send a message into Haraka via SMTP - you don't have to manually create a message and send it; it does all of that for you if properly configured.
Maybe if you are a bit more clear about what you are trying to do - we can tell you how to achieve it.
ok what im trying to do is make a simple reply, when i email at test@harakaserver.com it will reply the message we send back to the sender. but when there is an attachment, i need something like die(); in php, or maybe stop. ive read the docs about DENY an i think its the best thing that we need to do it so.
I'm still not 100% sure exactly what you mean. How about this:
var outbound = require('./outbound');
exports.hook_data = function (next, connection) {
// enable mail body parsing connection.transaction.parse_body = 1; // connection.relaying = true;
// attachment start connection.transaction.attachment_hooks(function (ctype, filename, body) {
// stop all the email that have attachment
if (filename)
{
connection.loginfo('found attachment: ' + filename);
connection.transaction.notes.has_attachment = true;
}
});
return next(); }
exports.hook_data_post = function (next, connection) { if (connection.transaction.notes.has_attachment) { return next(DENY, 'attachments not allowed'); }
var email_body_text = connection.transaction.body.body_text_encoded; var email_from = connection.transaction.mail_from; var email_to = connection.transaction.body.header.headers_decoded.to; var rcpt = connection.transaction.rcpt_to;
var contents = [ "From: Nadia t@dev.test.com", "To: " + email_from, "MIME-Version: 1.0", "Content-type: text/plain; charset=utf8", "Subject: Some subject here", "", "Some email body here", ""].join("\n");
// rcpt.forEach(function (r) { outbound.send_email(r, email_from, contents) }); outbound.send_email(rcpt[0].address, email_from, contents);
return next(); }
then loops again, i got two emails then die. what is going on here?
in plugins i only have this test.js and a rcpt_to.in_host_list