How can I use a different email send method for the Accounts.sendEnrollmentEmail method in Meteor? - email

I use Mandrill to send emails from within Meteor. I don't have the default email method configured. I use this smart package https://github.com/Wylio/meteor-mandrill
Is there a way to change the Accounts.sendEnrollmentEmail method to use a smart package to send the email?
Right now I get the error below when I try to use that method.
Here is my error trace
message: Invalid login - 435 4.7.8 Error: authentication failed:
421 4.7.0 ip-10-102-139-231 Error: too many errors stack:
AuthError: Invalid login - 435 4.7.8 Error: authentication failed:
at Object.Future.wait (/Users/Bechard/.meteor/packages/meteor-tool/.1.0.36.15lvyk8++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:326:15)
at smtpSend (packages/email/email.js:91)
at Object.Email.send (packages/email/email.js:168)
at Object.Email.send (packages/meteorhacks:kadira/lib/hijack/email.js:9)
at Object.Accounts.sendEnrollmentEmail (packages/accounts-password/password_server.js:460)
at Object.Utils.create_user (app/server/lib/globals.js:83:22)
at Meteor.methods.singleDonation (app/server/methods/donate.js:73:36)
at methodMap.(anonymous function) (packages/meteorhacks:kadira/lib/hijack/wrap_session.js:182)
at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1599)
at packages/ddp/livedata_server.js:648
- - - - -
421 4.7.0 ip-10-102-139-231 Error: too many errors
at SMTPClient._actionAUTHComplete (/Users/Bechard/.meteor/packages/email/.1.0.4.ioat51++os+web.browser+web.cordova/npm/node_modules/simplesmtp/lib/client.js:826:23)
at SMTPClient._onData (/Users/Bechard/.meteor/packages/email/.1.0.4.ioat51++os+web.browser+web.cordova/npm/node_modules/simplesmtp/lib/client.js:329:29)
at CleartextStream.emit (events.js:95:17)
at CleartextStream.<anonymous> (_stream_readable.js:748:14)
at CleartextStream.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:410:10)
at _stream_readable.js:403:7
at process._tickCallback (node.js:419:13)

Turns out I didn't declare the Mandrill key in my startup function.
I originally had this
Meteor.startup(function() {
return Meteor.Mandrill.config({
username: Meteor.settings.mandrillUsername
});
});
I changed it to this and the email sent fine.
Meteor.startup(function() {
return Meteor.Mandrill.config({
username: Meteor.settings.mandrillUsername,
"key": Meteor.settings.mandrillKey
});
});

Related

Salesforce making REST calls using access token uses local host rather instance url

I am using a ionic app and have implemented oauth using forcejs described here https://github.com/ccoenraets/forcejs/blob/master/README.md
my code looks like below:
getContacts(){
let service = DataService.getInstance();
service.query('select id, Name from contact LIMIT 50')
.then(response => {
let contacts = response.records;
console.log(JSON.stringify(contacts))
});
}
login(){
let oauth = OAuth.createInstance('mycousmerappid','','http://localhost:8100/tabs/tab1');
oauth.login().then(oauthResult => {
DataService.createInstance(oauthResult);
console.log("Logged Into Salesforce Successfully:::" + JSON.stringify(oauthResult));
this.getContacts()
});
}
the oauth token instance url and refresh token all comes up in login but get contact throws error as below
zone-evergreen.js:2952 GET http://localhost:8100/tabs/services/data/v41.0/query?q=select%20id%2C%20Name%20from%20contact%20LIMIT%2050 404 (Not Found)
scheduleTask # zone-evergreen.js:2952
scheduleTask # zone-evergreen.js:378
onScheduleTask # zone-evergreen.js:272
core.js:9110 ERROR Error: Uncaught (in promise): XMLHttpRequest: {"__zone_symbol__readystatechangefalse":[{"type":"eventTask","state":"scheduled","source":"XMLHttpRequest.addEventListener:readystatechange","zone":"angular","runCount":8}],"__zone_symbol__xhrSync":false,"__zone_symbol__xhrURL":"http://localhost:8100/tabs/services/data/v41.0/query?q=select%20id%2C%20Name%20from%20contact%20LIMIT%2050","__zone_symbol__xhrScheduled":true,"__zone_symbol__xhrErrorBeforeScheduled":false,"__zone_symbol__xhrTask":{"type":"macroTask","state":"scheduled","source":"XMLHttpRequest.send","zone":"angular","runCount":0}}
at resolvePromise (zone-evergreen.js:797)
at resolvePromise (zone-evergreen.js:754)
at zone-evergreen.js:858
at ZoneDelegate.invokeTask (zone-evergreen.js:391)
at Object.onInvokeTask (core.js:34182)
at ZoneDelegate.invokeTask (zone-evergreen.js:390)
at Zone.runTask (zone-evergreen.js:168)
at drainMicroTaskQueue (zone-evergreen.js:559)
at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:469)
at invokeTask (zone-evergreen.js:1603)
based on link i am not expecting it to use the base url localhost. Please advise how to fix this issue
i dont know how to resolve the same way but then i used direct http rest format using the accessToken and instanceUrl coming from oAuth. That works just fine

GitHub Probot : ERROR probot: Bad Request

I am developing an application for Probot. I have configured .envand already downloaded PEM file in the folder.
Here is the content of file index.js.
module.exports = (robot) => {
robot.on('issues.opened', async context => {
const params = context.issue({ body: 'Hello World!' })
return context.github.issues.createComment(params)
})
}
But I am getting this error.
ERROR probot: Bad Request
Error: Bad Request
at Request.callback (/media/ashutosh/ASHUTOSH ( PERSONAL )/Gsoc/probot/practice/ashutosh-probot/node_modules/superagent/lib/node/index.js:696:15)
at IncomingMessage.parser (/media/ashutosh/ASHUTOSH ( PERSONAL )/Gsoc/probot/practice/ashutosh-probot/node_modules/superagent/lib/node/index.js:906:18)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickDomainCallback (internal/process/next_tick.js:218:9)
How to fix this issue?
This error not because of Probot, but the error is on GitHub ends.
This error is possibly because you have entered wrong User authorization call back URL, while creating a new GitHub application. Updating this will fix the issue.

Meteor email sending buggy when sending multiple emails in a short time

Quite new to Meteor.
I am sending an email when a user presses a button. I get these errors when I press the button:
I20170801-10:37:06.225(8)? Exception in defer callback: Error: Mail command failed: 503 5.5.2 Sender already specified [KL1PR03MB1416.apcprd03.prod.outlook.com]
I20170801-10:37:06.226(8)? at Object.Future.wait (/Users/duminda/.meteor/packages/meteor-tool/.1.4.3_2.1bvf0xf++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:449:15)
I20170801-10:37:06.226(8)? at SMTPConnection._syncSend (packages/meteor.js:213:24)
I20170801-10:37:06.226(8)? at smtpSend (packages/email.js:112:8)
I20170801-10:37:06.227(8)? at Object.Email.send (packages/email.js:208:5)
I20170801-10:37:06.227(8)? at server/Travel/methods.js:5:19
I20170801-10:37:06.228(8)? at [object Object]._.extend.withValue (packages/meteor.js:1122:17)
I20170801-10:37:06.228(8)? at packages/meteor.js:445:45
I20170801-10:37:06.229(8)? at runWithEnvironment (packages/meteor.js:1176:24)
I20170801-10:37:06.229(8)? - - - - -
I20170801-10:37:06.230(8)? at SMTPConnection._formatError (/Users/duminda/.meteor/packages/email/.1.2.0.cuwbi8++os+web.browser+web.cordova/npm/node_modules/smtp-connection/lib/smtp-connection.js:528:15)
I20170801-10:37:06.230(8)? at SMTPConnection._actionMAIL (/Users/duminda/.meteor/packages/email/.1.2.0.cuwbi8++os+web.browser+web.cordova/npm/node_modules/smtp-connection/lib/smtp-connection.js:1252:30)
I20170801-10:37:06.230(8)? at SMTPConnection.<anonymous> (/Users/duminda/.meteor/packages/email/.1.2.0.cuwbi8++os+web.browser+web.cordova/npm/node_modules/smtp-connection/lib/smtp-connection.js:759:14)
I20170801-10:37:06.231(8)? at SMTPConnection._processResponse (/Users/duminda/.meteor/packages/email/.1.2.0.cuwbi8++os+web.browser+web.cordova/npm/node_modules/smtp-connection/lib/smtp-connection.js:669:16)
I20170801-10:37:06.231(8)? at SMTPConnection._onData (/Users/duminda/.meteor/packages/email/.1.2.0.cuwbi8++os+web.browser+web.cordova/npm/node_modules/smtp-connection/lib/smtp-connection.js:493:10)
I20170801-10:37:06.231(8)? at emitOne (events.js:77:13)
I20170801-10:37:06.232(8)? at TLSSocket.emit (events.js:169:7)
I20170801-10:37:06.232(8)? at readableAddChunk (_stream_readable.js:153:18)
I20170801-10:37:06.232(8)? at TLSSocket.Readable.push (_stream_readable.js:111:10)
I20170801-10:37:06.233(8)? at TLSWrap.onread (net.js:537:20)
My code:
if(response === 1) {
sendDeferredEmail({
to: email,
from: "smtp#***.com",
subject: "New Travel Request pending response by " + user.username,
html: user.username + " added a new travel request." + "<br>"
});
...
function sendDeferredEmail(params)
{
try {
Meteor.defer(function () {
Email.send({to: params.to, from: params.from, subject: params.subject, html: params.html});
});
}
catch(e)
{
console.log("Caught exception when sending email:\n" + e);
}
}
The email setup:
process.env.MAIL_URL = 'smtp://smtp#***:587';
What is going wrong here and how can I fix it?
I would comment but lack reputation... How fast are you pressing the buttons? Most online mail servers don't allow relay sends to avoid users spamming. Have you tried setting this as a server side function and using Meteor.call() to trigger an Email.send()?

Erlang and PostgreSQL

I try to execute simple PostgreSQL query with erlang and epgsql.
I do:
{ok, C} = pgsql:connect("localhost", "shk", "qwerty", [{database, "mydb"}]).
>> {ok,<0.34.0>}
Then:
{ok, Cols, Rows} = pgsql:squery(C, "select * from users").
But i got error:
=ERROR REPORT==== 27-Apr-2012::17:58:23 ===
** State machine <0.34.0> terminating
** Last message in was {'EXIT',<0.32.0>,
{{badmatch,
{error,
{error,'ð\236ð¨ð\230ð\221ð\232ð\220',<<"42P01">>,
<<208,190,209,130,208,189,208,190,209,136,208,181,
208,189,208,184,208,181,32,34,109,121,100,98,34,
32,208,189,208,181,32,209,129,209,131,209,137,
208,181,209,129,209,130,208,178,209,131,208,181,
209,130>>,
[{position,<<"15">>}]}}},
[{erl_eval,expr,3}]}}
** When State == ready
** Data == {state,undefined,<0.35.0>,5000,
[{<<"application_name">>,<<>>},
{<<"client_encoding">>,<<"UTF8">>},
{<<"DateStyle">>,<<"ISO, DMY">>},
{<<"integer_datetimes">>,<<"on">>},
{<<"IntervalStyle">>,<<"postgres">>},
{<<"is_superuser">>,<<"off">>},
{<<"server_encoding">>,<<"UTF8">>},
{<<"server_version">>,<<"9.0.7">>},
{<<"session_authorization">>,<<"shk">>},
{<<"standard_conforming_strings">>,<<"off">>},
{<<"TimeZone">>,<<"posixrules">>}],
undefined,undefined,undefined,
{30932,488494147},
{statement,undefined,undefined,undefined},
73}
** Reason for termination =
** {{badmatch,{error,{error,'ð\236ð¨ð\230ð\221ð\232ð\220',<<"42P01">>,
<<208,190,209,130,208,189,208,190,209,136,208,181,
208,189,208,184,208,181,32,34,109,121,100,98,34,
32,208,189,208,181,32,209,129,209,131,209,137,
208,181,209,129,209,130,208,178,209,131,208,181,
209,130>>,
[{position,<<"15">>}]}}},
[{erl_eval,expr,3}]}
What's wrong i do? How can i fix it?
Thank you.
The error string seems to be in russian if I recognize the characters.
To view the response you can use the following command:
io:format("~ts",[<<208,190,209,130,208,189,208,190,209,136,208,181,
208,189,208,184,208,181,32,34,109,121,100,98,34,
32,208,189,208,181,32,209,129,209,131,209,137,
208,181,209,129,209,130,208,178,209,131,208,181,
209,130>>]).
отношение "mydb" не существует
A quick google translate makes me think the database mydb does not exist or you do not have permissions to use it.
try simply doing
Response = pgsql:squery(C, "select * from mydb"),
io:format("~p~n",[Response]).
And see what he is giving back from the server, maybe you have typo or table don't exists etc.
also check this out http://www.erlangatwork.com/2009/01/erlang-and-postgresql.html
From epgsql docs:
Errors
Errors originating from the PostgreSQL backend are returned as {error, #error{}},
see pgsql.hrl for the record definition. epgsql functions may also return
{error, What} where What is one of the following:
{unsupported_auth_method, Method} - required auth method is unsupported
timeout - request timed out
closed - connection was closed
sync_required - error occured and pgsql:sync must be called
Try to include pgsql.hrl, capture the error and print the error message, that should point you to the right direction.

displaying page not found error with zend acl

whenever a controller is called if it is not registered in zend acl then we ususally get erro r like this
Fatal error: Uncaught exception 'Zend_Acl_Exception' with message
'Resource 'hsfasfdadsf' not found' in /usr/share/php/libzend-framework-php/Zend/Acl.php:365
Stack trace:
#0 /var/www/update/library/Management/Access.php(55): Zend_Acl->get('hsfasfdadsf')
#1 /usr/share/php/libzend-framework-php/Zend/Controller/Plugin/Broker.php(309): Management_Access->preDispatch(Object(Zend_Controller_Request_Http))
#2 /usr/share/php/libzend-framework-php/Zend/Controller/Front.php(941):
isn't there a way to check if the controller and action is registered in zend acl, i tried
if(!$acl->get($controller))
{
$request->setControllerName('error');
$request->setActionName('notfound');
}
but did not work
First solution:
Avoid those exceptions, e.g.
if (!$acl->has($your_resource)) {
// .. handle it the way you need
}
Second one
Handle those exceptions in ErrorController, i.e.:
if ($errors->exception instanceof Zend_Acl_Exception) {
// send needed headers...
// prepare log message...
// render info: resource_not_found.phtml
$this->_helper->viewRenderer('resource_not_found');
}