New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Transaction.notes not passing to Hmail.todo.notes #1293
Comments
Because you're setting the notes in the callback which is run after the outbound.send_email returns.... |
Thanks @smfreegard. If I set the notes in an event previous to the them, inside a callback, when it arrives to the Look up the code var outbound = require('./outbound');
var request = require('request');
exports.register = function() {
this.register_hook('data', 'query_the_api');
this.register_hook('queue', 'send_email');
this.register_hook('get_mx', 'change_smtp_server');
};
exports.query_the_api = function(next, connection)
{
request("http://google.com", function(){
connection.transaction.notes.send_server = 'tulpep-com.mail.protection.outlook.com';
connection.transaction.notes.send_server_port = 25;
return next();
});
};
exports.send_email = function (next, connection) {
connection.loginfo("There is info" + connection.transaction.notes.send_server);
var contents = [
"From: " + "ricardo.polo@tulpep.com",
"To: " + "ricardo.polo@tulpep.com",
"MIME-Version: 1.0",
"Content-type: text/plain; charset=us-ascii",
"Subject: Some subject here",
"",
"Some email body here",
""].join("\n");
outbound.send_email(connection.transaction.mail_from, connection.transaction.rcpt_to, contents, function (code, msg) {
switch (code) {
case OK: return next(OK, msg);
case DENY: return next(DENY, msg);
default: return next(DENYSOFT, msg);
}
});
};
exports.change_smtp_server = function (next, hmail, domain) {
var mx = {
priority: 0,
exchange: hmail.todo.notes.send_server,
port: hmail.todo.notes.send_server_port
};
return next(OK, mx);
}; Why values are past from |
I was thinking about it and found this is not about a wrong callback use. Looking at the code I see that when you use |
Put them in a header?
|
@baudehlo that is not possible in our requirements, we cannot have the values in headers. I created a PR that fixes this. |
You could use send_trans_email then.
|
@baudehlo yes I know but we need a bran new email, not keeping anything of the original one. We just want to use some notes to be used in the So.. this is why I we created the PR #1295. To can use |
We are creating a plugin that changes the SMTP server based in some info from an API. So we plan to get the info in the
queue
event, and store the SMTP server in the transaction.notes and then use it in theget_mex
hook.Look up this plugin code
It is supposed acording to docs that everything in
transaction.notes
will be inhmail.todo.notes
, but in this casetodo.notes.send_server
is empty. Why could this be happening?Any idea, maybe @baudehlo @smfreegard @msimerson ?
Thank you so much for you help!!
The text was updated successfully, but these errors were encountered: