Closed wpoosanguansit closed 13 years ago
There are two components to email - the envelope, which the end-user never sees, which is what is used for delivering the message, and the body of the email, which is what you see in email clients when you open the mail. The two don't have to match, and are only related to each other by courtesy. In Haraka you can modify the headers through the Transaction object API, but it's separate to modifying the envelope, which is all I do in the tutorial.
Thank you for your help. I hope you don't mind I ask further questions to help clarify my understanding. So in this case, the one used to deliver the mail was changed, which is in the envelop. How does, let's say, qmail pick that up to know where to send the mail to? Also, is there an example where the change is also pushed to the body of the email through Transaction object API? I will be looking through the source code but a pointer would definitely be a great help.
Thank you.
No I don't mind more questions. But I'll keep the bug closed if that's OK.
The SMTP protocol carries the envelope data, so if you forward to Qmail it knows the changes you made behind the scenes.
To change the headers you'd need to first delete the original To line:
transaction.remove_header('To');
And then add the new one:
transaction.add_header('To', new_recipient);
Hope that helps.
Thank you. That does it. For it might help someone else, I put the body text changing code in
exports.hook_data = function(next, connection) { // // enable mail body parsing connection.transaction.parse_body = 1; next(); }
exports.hook_queue = function(next, connection) { connection.transaction.remove_header('To'); connection.transaction.add_header('To', changedTo);
next();
}
as the hook_rcpt does not have access to the body text yet.
Thanks for your help.
--- On Fri, 11/11/11, baudehlo reply@reply.github.com wrote:
From: baudehlo reply@reply.github.com Subject: Re: [Haraka] To: field does not get changed in Tutorial? (#120) To: "wpoosanguansit" wpoosanguansit@yahoo.com Date: Friday, November 11, 2011, 10:05 AM No I don't mind more questions. But I'll keep the bug closed if that's OK.
The SMTP protocol carries the envelope data, so if you forward to Qmail it knows the changes you made behind the scenes.
To change the headers you'd need to first delete the original To line:
transaction.remove_header('To');
And then add the new one:
transaction.add_header('To', new_recipient);
Hope that helps.
Reply to this email directly or view it on GitHub: https://github.com/baudehlo/Haraka/issues/120#issuecomment-2708994
FWIW the headers are always parsed, you don't need to enable parse_body for this. Also this should be done in data_post just for cleanliness sake.
Hi,
I am just trying out the tutorial to understand how to write plugins. From the tutorial the To: was changed on the console -
[INFO] [rcpt_to.lookup] Email address now: booya@haraka.local
However when I checked in the /tmp/mail.eml file, the content says that the To: was not changed.
Fri, 11 Nov 2011 08:50:49 -0500 Date: Fri, 11 Nov 2011 08:50:49 -0500 To: booya-20120101@haraka.local From: here@here.com Subject: test Fri, 11 Nov 2011 08:50:49 -0500 X-Mailer: swaks v20100211.0 jetmore.org/john/code/swaks/
This is a test mailing
I am just curious how does the mail get send in the next phase? And where was the change saved to? Thank you for your help.