akhoury / nodebb-plugin-emailer-mandrill

An emailer plugin for NodeBB using Mandrill as a third party service
MIT License
3 stars 11 forks source link

Unable to change the from_email #11

Closed KanwalPrakashSingh closed 9 years ago

KanwalPrakashSingh commented 9 years ago

How do I change the from_email ?

I'm unable to send the mail using my own domain, everything gets sent via some random domain (say no-reply@xyz.com)

rudimk commented 9 years ago

I seem to be facing this issue too. Any pointers, @akhoury?

rudimk commented 9 years ago

Okay, so a quick fix is to modify the index.js file in <your nodebb installation>/node_modules/nodebb-plugin-emailer-mandrill and manually set the from_email parameter here:

mandrill('/messages/send', {
            message: {
                to: [{email: data.to, name: data.toName}],
                subject: data.subject,
                from_email: '',
                from_name: '',
                html: data.html,
                text: data.plaintext,
                auto_text: !!!data.plaintext,
                headers: headers
            }
        }, function (err, response) {
            if (!err) {
                winston.verbose('[emailer.mandrill] Sent `' + data.template + '` email to uid ' + data.uid);
            } else {
                winston.warn('[emailer.mandrill] Unable to send `' + data.template + '` email to uid ' + data.uid + '!!');
                winston.warn('[emailer.mandrill] Error Stringified:' + JSON.stringify(err));
            }
        });

It's not elegant, and chances are that a plugin update might overwrite these changes, but it works for now.

KanwalSingh commented 9 years ago

@rudimk actually /admin/settings/email I set a from address via this. it works !