javascript - Getting a syntax error when invoking meteor's Email.send -
i'm trying set email sending using meteor , mailgun. before, used default meteor options , if app deployed emails sent methods themself should fine. problem app run locally need set smtp server. i'm trying use default sandbox mailgun provided because don't know domain yet i'm getting syntax error. here's meteor console says. unfortunately can't understand of this. piece of code appears in meteor.methods.
i20150825-08:50:51.482(2)? exception while invoking method 'sendemail' sendererror: mail command failed - 501 syntax error i20150825-08:50:51.484(2)? @ object.future.wait (/home/m/.meteor/packages/meteor-tool/.1.1.4.1ih17fx++os.linux.x86_64+web.browser+web.cordova/mt-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15) i20150825-08:50:51.484(2)? @ smtpsend (packages/email/email.js:76:1) i20150825-08:50:51.484(2)? @ object.email.send (packages/email/email.js:153:1) >i20150825-08:50:51.485(2)? @ [object object].meteor.methods.sendemail (app/server/methods.js:11:19) i20150825-08:50:51.485(2)? @ maybeauditargumentchecks (packages/ddp/livedata_server.js:1617:1) i20150825-08:50:51.485(2)? @ packages/ddp/livedata_server.js:648:1 i20150825-08:50:51.485(2)? @ [object object]._.extend.withvalue (packages/meteor/dynamics_nodejs.js:56:1) i20150825-08:50:51.485(2)? @ packages/ddp/livedata_server.js:647:1 i20150825-08:50:51.485(2)? @ [object object]._.extend.withvalue (packages/meteor/dynamics_nodejs.js:56:1) i20150825-08:50:51.485(2)? @ [object object]._.extend.protocol_handlers.method (packages/ddp/livedata_server.js:646:1) i20150825-08:50:51.485(2)? - - - - - i20150825-08:50:51.486(2)? @ smtpclient._actionmail (/home/m/.meteor/packages/email/.1.0.6.1rj8k8w++os+web.browser+web.cordova/npm/node_modules/simplesmtp/lib/client.js:879:23) i20150825-08:50:51.486(2)? @ smtpclient._ondata (/home/m/.meteor/packages/email/.1.0.6.1rj8k8w++os+web.browser+web.cordova/npm/node_modules/simplesmtp/lib/client.js:329:29) i20150825-08:50:51.486(2)? @ cleartextstream.emit (events.js:95:17) i20150825-08:50:51.486(2)? @ cleartextstream.<anonymous> (_stream_readable.js:765:14) i20150825-08:50:51.486(2)? @ cleartextstream.emit (events.js:92:17) i20150825-08:50:51.486(2)? @ emitreadable_ (_stream_readable.js:427:10) i20150825-08:50:51.486(2)? @ _stream_readable.js:420:7 i20150825-08:50:51.486(2)? @ process._tickcallback (node.js:442:13)
my problem started after changed mail_url variable:
process.env.mail_url = 'smtp://postmaster%40sandbox:password@smtp.mailgun.org:587';
the error shows syntax error @ 11:19 in file . in email.send
if (meteor.isserver) { meteor.startup(function () { process.env.mail_url = 'smtp://postmaster%40sandbox:password@smtp.mailgun.org:587'; }); meteor.methods({ sendemail: function (to, from, subject, text) { check([to, from, subject, text], [string]); // let other method calls same client start running, // without waiting email sending complete. this.unblock(); email.send({ to: to, from: from, subject: subject, text: text }); }); }
this example call method in register form:
template.register.events({ 'submit form': function (event) { event.preventdefault(); var remail = $('[id=registeremail]').val(); var rpassword = $('[id=registerpassword]').val(); var passwordconfirm = $('[id=passwordconfirm]').val(); var rname = $('#registername').val(); var rsurname = $('#registersurname').val(); if (isemail(remail) && arevalidpasswords(rpassword, passwordconfirm)) { var iduser = accounts.createuser({ email: remail, password: rpassword, profile: { 'name': rname, 'surname': rsurname } }, function (error) { if (error) { window.alert(error.reason); } else { router.go("home"); } } ); meteor.call('sendemail',remail,'sentfrom','subject','content'); meteor.settimeout(function(){router.go('dashboard')}, 2000); } else return false; } });
i'm using exact method mentioned in meteor docs , worked before changing smtp.
your from
argument has in correct email address format ("******@****.**") in order email sent. right giving "sentfrom" sender address!
have @ the example again:
meteor.call('sendemail', 'alice@example.com', 'bob@example.com', 'hello meteor!', 'this test of email.send.');
Comments
Post a Comment