Meteor mail not sending despite setting MAIL_URL environment variable - javascript

I'm getting this error message in the terminal "Mail not sent; to enable sending, set the MAIL_URL environment variable." despite setting MAIL_URL environment variable. After this message the whole mail content html gets dumped in the terminal. I'm using 2 meteor packages for sending email: yogiben:pretty-emails and email with mailgun api service.
Here's the source code for the mail config and sending email:
if Meteor.isServer
Meteor.startup ->
process.env.MAIL_URL = 'smtp://sandboxid.mailgun.org:mypassword#smtp.mailgun.org:587'
return
PrettyEmail.options =
from: 'primaryemail#gmail.com'
siteName: 'Meteor Test'
companyAddress: 'sdfsf, gdfg-df'
companyName: 'Code to Create'
companyUrl: 'http://example.com'
Accounts.sendVerificationEmail ->
Meteor.userId()
This file is kept inside Project_Directory/both/_config directory. I'm currently developing this app on local ubuntu server.

I think the call to sendVerificationEmail should be:
Accounts.sendVerificationEmail Meteor.userId()
as per the docs at http://docs.meteor.com/#/full/accounts_sendverificationemail
If that code is the exact code you're using, then you may be having issues because of the order in which each piece of code runs (callbacks run asynchronously). The startup callback will run after PrettyEmail.options and Accounts.sendVerificationEmail
If you indent those two sections as follows it should work as expected:
if Meteor.isServer
Meteor.startup ->
process.env.MAIL_URL = 'smtp://sandboxid.mailgun.org:mypassword#smtp.mailgun.org:587'
PrettyEmail.options =
from: 'primaryemail#gmail.com'
siteName: 'Meteor Test'
companyAddress: 'sdfsf, gdfg-df'
companyName: 'Code to Create'
companyUrl: 'http://example.com'
Accounts.sendVerificationEmail Meteor.userId()
Failing that it may also be worth setting MAIL_URL before running the app, for example:
MAIL_URL="smtp://sandboxid.mailgun.org:mypassword#smtp.mailgun.org:587" meteor
EDIT:
Your example code is not secure: If you are keeping this code in the 'both' directory, then anyone accessing your website will be able to see your mailgun credentials. You should put server code in the 'server' directory or at the very least set the MAIL_URL outside of your code as shown above.

I came across the same error. The trick was to not include the MAIL_URL in the application, but in the terminal where you run meteor itself.
Use the following command to run meteor:
MAIL_URL="smtp://postmaster#sandbox****.mailgun.org:XXXX#smtp.mailgun.org:587" meteor
I tried this on Ubuntu Terminal, hence should work on Mac as well.

Related

You're not authorized to run analysis. Please contact the project administrator Sonarqube local

I have very basic setup of sonarqube. It is in initial phase only and it's kind of strange that I'm not able to access sonarqube report at localhost:9090 (default is of course 9000 but I just changed it to 9090). I'm able to login to sonarqube at localhost:9090
When I run node sonarqube-scanner.js command, it gets executed successfully as shown below but it gives authorization error,
INFO: Analysis report generated in 225ms, dir size=144.8 kB INFO:
Analysis report compressed in 338ms, zip size=49.6 kB INFO:
INFO: EXECUTION FAILURE INFO:
INFO: Total time: 6:16.209s INFO: Final Memory: 16M/60M INFO:
ERROR: Error during SonarScanner execution ERROR: You're not
authorized to run analysis. Please contact the project administrator.
My sonarqube-scanner.js file is as below, as you can I tried with everything eg login, password, token
const scanner = require('sonarqube-scanner');
scanner(
{
serverUrl: "http://localhost:9090",
login: "XXX",
password: "XXX",
token: "sqa_bXXXXXXXXXXXXXXXXX",
options: {
"sonar.sources": "./src"
},
},
() => process.exit()
);
And I use sonarqube docker image as below
docker-compose.yml
version: "3"
services:
sonarqube:
image: sonarqube:community
depends_on:
- db
environment:
SONAR_JDBC_URL: jdbc:postgresql://db:5432/sonar
SONAR_JDBC_USERNAME: sonar
SONAR_JDBC_PASSWORD: sonar
volumes:
- sonarqube_data:/opt/sonarqube/data
- sonarqube_extensions:/opt/sonarqube/extensions
- sonarqube_logs:/opt/sonarqube/logs
ports:
- "9090:9000"
db:
image: postgres:12
environment:
POSTGRES_USER: sonar
POSTGRES_PASSWORD: sonar
volumes:
- postgresql:/var/lib/postgresql
- postgresql_data:/var/lib/postgresql/data
volumes:
sonarqube_data:
sonarqube_extensions:
sonarqube_logs:
postgresql:
postgresql_data:
NOTE : At localhost:9090->Administration->Security-> all checkboxes are checked for all users. Still it is not working.
I literally don't know if anything has changed but I observed one thing as below,
Earlier few days ago,
I was able to generate the report directly to localhost:9090 but all of sudden from today it started indicating You're not authorized to run analysis. Please contact the project administrator.
The Problem
Earlier it used to generate the report on-the-fly directly and create the project on its own. What I mean by that is even when your server is not configured with any project (consider it is completely blank) and if you are running the sonar analysis for the first time, it used to create the project on-the-fly on the sonarqube-server (localhost).
This not not the case anymore (at least in my case)
in my case, my sonarqube-server was completely empty (without any project) and when I was trying to run the sonar analysis again for the first time, it started throwing the error that you are not authorized.
Solution
I just had to create the project manually in sonarqube-server. Then when I ran the analysis, it ran successfully without any problem.
I hope this answer will help someone in future.
It was working for me with 9.4, but not anymore with 9.5.
Did you upgrade recently to 9.5 version?
Perhaps linked to: https://jira-legacy-sonarsource.valiantys.net/browse/SONAR-16260.

I faced a problem when I used .env file in node.js

In my node.js project, I want to use environment variables for saving MongoDB's user name and password. When I directly use username and password then it is working completely. But when I used template string and process.env.varName then I got bad auth: Authentication failed error message.
ok: 0,<br/>
code: 8000,<br/>
codeName: 'AtlasError',<br/>
[Symbol(errorLabels)]: Set(0)<br/>
{}

Netlify "user is not authorized to perform: dynamodb:PutItem on resource"

I'm trying to get a hand with Netlify and AWS. I have downloaded a sample REST API preset from the official serverless site here.
The site worked locally after serverless deploy including the create route, used to add new todo elements into the db (API gateway on Amazon shows no issues)
I wanted to test how would it work on netlify, so I created a bitbucket repo from the file and uploaded it into the netlify servers.
From the start, there were minor issues. Such as an error claiming that TableName which in code is created from process.env.DYNAMODB_TABLE was not provided.
After replacing the value with the value of the field, I got an error saying that
{User: arxxxx:assumed-role/aws-lambda-execute/xxx is not authorized to perform: dynamodb:PutItem on resource: arn:aws:dynamodb:us-xxx-1:xxx:table/serverless-rest-api-with-dynamodb-dev","code":"AccessDeniedException","time":"xxx","requestId":"xxx","statusCode":400,"retryable":false,"retryDelay":30.76949318814495}
The issue suggests that my serverless parameters are wrong, however I do have the permissions set:
provider:
name: aws
runtime: nodejs6.10
environment:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
- dynamodb:GetItem
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
And all seem to work fine when the data is local.
Has anyone ever had such issue?

How to set up SSH Agent Forwarding in node.js (simple-ssh module)?

I am new to this node.js and using module simple-ssh for executing shell commands from my windows to remote server.
Whenever I run my code, the console curses me with [Error: Authentication failure. Available authentication methods: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive].
I have already put an RSA private-key file, and set the Windows ENV variable SSH_AUTH_SOCK. But still it keeps giving the error.
Below is the code snippet which I wrote for simple-ssh:
var ssh = new SSH({
host: sshHost,
user: 'root',
timeout: 11000000,
key: require('fs').readFileSync("D:/Keys_pair_prvt_pub/rsa_key"),
agent: process.env.SSH_AUTH_SOCK,
agentForward: true
});
When I am trying to SSH the remote from my windows cmd-prompt, it is giving me error:
$> ssh -A <myRemote.host.com>
ssh : The term 'ssh' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
Am I missing anything? If yes, then how do I overcome this ?
Any help will be appreciated :)
Thanks.
Your key needs to be added to ~/.ssh/authorized_keys on the server for your key to work.
mscdex npm package SSH2, which simple-ssh wraps, has this in the docs for using ssh.agent on windows:
`agent - string - Path to ssh-agent's UNIX socket for ssh-agent-based user authentication. Windows users: set to 'pageant' for authenticating with Pageant or (actual) path to a cygwin "UNIX socket."

Setting up Mailgun with Meteor JS on Heroku - Error 554

I've been trying to set up my mailgun to work with my Meteor app. When I use the sandbox, it works perfectly, but when I use the custom domain, I get an error:
Exception while invoking method 'forgotPassword' DeliveryError: Message delivery failed: 554 The domain is unverified and requires DNS configuration. Log in to your control panel to view required DNS records.
I've set up my configurations, so when I heroku config on the cmd, I get my vars and they're all correct.
MAILGUN_API_KEY: key-<api>
MAILGUN_DOMAIN: <appname>.herokuapp.com
MAILGUN_PUBLIC_KEY: pubkey-<key>
MAILGUN_SMTP_LOGIN: postmaster#<appname>.herokuapp.com
MAILGUN_SMTP_PASSWORD: <password>
MAILGUN_SMTP_PORT: 587
I've also set my app's environment variables in server/server.js like this:
Meteor.startup(function(){
process.env.MAIL_URL = 'smtp://postmaster%40<appname>.herokuapp.com:<password>#smtp.mailgun.org:587';
});
Am I missing something?

Categories

Resources