Mariasql with nodejs not working - mariadb

I did:
var MariaSQLClient = require('mariasql');
var maria_connection = new MariaSQLClient({ host: '127.0.0.1', user: 'root', password: 'root', db: 'db1' })
But when i check whether it is connected or not using:
maria_connection.connected
false
It returns false always

Related

When I put my password Environment Variables it won't work

My code works as below in my localhost. What I'm trying to do is put my password in my .envlocal but it won't work.
working code
export default function (req, res) {
let nodemailer = require('nodemailer')
const transporter = nodemailer.createTransport({
port: 465,
host: "smtp.gmail.com",
auth: {
user: 'myEmail#gmail.com',
pass: 'password123',
},
secure: true,
});
const mailData = {
from: 'keshibatmail#gmail.com',
to: 'kensukeshibata#gmail.com',
subject: `Message From ${req.body.name}`,
text: req.body.message + " | Sent from: " + req.body.email,
html: `<div>${req.body.message}</div><p>Sent from: ${req.body.email}</p>`
}
transporter.sendMail(mailData, function (err, info) {
if(err)
console.log(err)
else
console.log(info);
})
console.log(req.body)
res.send('success')
}
What I tried.
My next.js is
"next": "10.x"
,
So I should be able to use this since my next.js is higher than 9.4 https://nextjs.org/docs/api-reference/next.config.js/environment-variables
I made .env.local file
NEXT_PUBLIC_PASSWORD=password123
then process.env.NEXT_PUBLIC_PASSWORD
I tried without NEXT_PUBLIC_ as well.
I get this error.
response: '535-5.7.8 Username and Password not accepted.
const transporter = nodemailer.createTransport({
port: 465,
host: "smtp.gmail.com",
auth: {
user: myEmail#gmail.com,
pass: process.env.NEXT_PUBLIC_PASSWORD,
},
secure: true,
});

openstack npm pkgcloud createImage() function not working

I am trying to create an image of an instance in openstack using npm pkgcloud.
For this I am using the code as below:
var openstack_client_compute = null;
openstack_client_compute = pkgcloud.compute.createClient({
provider: PROVIDER, // required
username: USERNAME, // required
password: PASSWORD, // required
region: REGION,
authUrl: AUTH_URL // required
});
options = {
name: 'image1', // required
server: '0e4d56a2-173a-425d-befd-cec366605522' // required
};
openstack_client_compute.createImage(options, function(err, image){
if(err){
console.log(err);
}
console.log(image);
});
I am getting the following error :
name: 'Error',
provider: 'openstack',
failCode: 'Service Unavailable',
statusCode: 503,
href: 'http://controller:8774/v2.1/6af81940df89199f088beba7d93/servers/0e4d56a2-173a-425d-befd-cec366605522/action',method: 'POST',
headers:
{ server: 'squid',
'mime-version': '1.0',
date: 'Mon, 09 Apr 2018 07:21:15 GMT',
'content-type': 'text/html;charset=utf-8',
'content-length': '3012',
'x-squid-error': 'ERR_DNS_FAIL 0',
'x-cache': 'MISS from lproxy',
'x-cache-lookup': 'MISS from proxy:8080',
connection: 'close' },
Note : other functions such as createStack deleteStack getStack etc are functioning properly
It is showing the error that unable to resolve host name (controller is not getting resolved to IP) the code is failing due to that.
Any possibility that a change in openstack configuration may resolve it.
If yes what changes are needed?

Can't send emails using SwiftMailer (Symfony4): wrong SMTP parameters?

I'm coding a small website using Symfony 4.
There's a simple contact form that is supposed to send emails, seemed easy until I realize I can't configure it ^^
I've followed Symfony doc instructions from here:
[https://symfony.com/doc/current/email.html][1]
Meaning mainly having the Swift mailer dependy:
composer require mailer
And my Controller looks like this:
/**
* #Route("/contact", name="contact_handling")
*/
public function contactHandler(Request $request, \Swift_Mailer $mailer)
{
$contact = new Contact();
$form = $this->createForm(ContactType::class, $contact);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$message = (new \Swift_Message('Hello Email'))
->setFrom('send#example.com')
->setTo('myownemail#hotmail.fr')
->setBody("plopppp mail")
;
$mailer->send($message);
$contact = $form->getData();
return $this->render('home.html.twig', array(
'form' => $form->createView(),
));
}
return $this->render('home.html.twig', array(
'form' => $form->createView(),
));
No matter what it does next in the return (I'm also trying to figure out how to avoid the page reload and just return an answer like "OK" or "not OK" then my Javascript pops up a message)
For dev environment (I'll have the same problem when moving to prod by the way),
my .env conf file has this parameter:
MAILER_URL=smtp://smtp-mail.outlook.com:587?encryption=tls&username=myownemail#hotmail.fr&password=mypwd
while trying to use my own email account, which could be my problem
Smtp address, port and encryption are some parameters found on website like this one:
[https://www.lifewire.com/what-are-the-outlook-com-smtp-server-settings-1170671][1]
Of course, I've never received anything.
If someone familiar whith this could help me it would be very nice :)
I'm using Windows10 + PhpStorm + php7 + built-in symfony server
Thanks!
Edit:
Output from: php bin/console debug:config SwiftmailerBundle
swiftmailer:
default_mailer: default
mailers:
default:
url: '%env(MAILER_URL)%'
spool:
type: memory
path: 'C:\www\h4h\var\cache\dev/swiftmailer/spool'
id: null
transport: smtp
command: '/usr/sbin/sendmail -bs'
username: null
password: null
host: localhost
port: null
timeout: 30
source_ip: null
local_domain: null
encryption: null
auth_mode: null
delivery_addresses: { }
logging: true
delivery_whitelist: { }
Edit 2:
I've just tried putting the conf in the config/packages/swiftmailer.yaml without more success, but at least, php bin/console debug:config SwiftmailerBundle outputs the correct info:
swiftmailer:
transport: gmail
username: mylogin
password: mypwd
host: smtp.gmail.com
port: 587
encryption: ssl
auth_mode: login
spool:
type: file
path: '%kernel.cache_dir%/swiftmailer/spool'
sender_address: ~
antiflood:
threshold: 99
sleep: 0
delivery_addresses: []
disable_delivery: ~
logging: '%kernel.debug%'

Nodemail to send mail for firebase app with service account

I get the following message when trying to send mail with Nodemailer :
'535-5.7.8 Username and Password not accepted.
Learn more at\n535 5.7.8 https://support.google.com/mail/?p=BadCredentials y42sm13399804wrc.51 - gsmtp',
responseCode: 535,
command: 'AUTH XOAUTH2' }
I am using a service account from a firebase project, and have granted access to the GMail API. But the nodemailer docs for 2LO is really scarce so I wonder if anyone could help me find if I use the correct credentials ?
user (functions.config().gmail.user) : myfirebaseproject#appspot.gserviceaccount.com
-
function sendContactMail(contactName, contactEmail, contactDate, contactText) {
// Create transport
let transporter = nodemailer.createTransport({
host: 'smtp.gmail.com',
port: 465,
secure: true,
auth: {
type: 'OAuth2',
user: functions.config().gmail.user,
serviceClient: functions.config().gmail.client_id,
privateKey: functions.config().gmail.private_key
//accessToken: 'ya29.Xx_XX0xxxxx-xX0X0XxXXxXxXXXxX0x',
//expires: 1484314697598
}
});
// Mail Options
let mailOptions = {
from: `"${APP_NAME}" <${SENDER}>`,
replyTo: `${contactEmail}`,
to: 'recipient#gmail.com',
subject: `Nouveau contact photo de ${contactName}`,
html: `Nom : ${contactName}<br/>
Email : ${contactEmail}<br/>
Date du mariage : ${contactDate}<br/>
Message : ${contactText}`,
disableFileAccess: true,
disableUrlAccess:true
};
// Send Mail
return transporter.sendMail(mailOptions);
}
Has your account two steps authentication enabled? In that case generate an app password on https://myaccount.google.com/apppasswords and use it instead of your normal password:
const mailTransport = nodemailer.createTransport(
`smtps://user#gmail.com:generatedAppPassword#smtp.gmail.com`);
I have Cloud Function with this code and it's work fine. Try this
mailTransport = nodemailer.createTransport({
service: 'Gmail',
auth: {
user: ${email},
pass: ${password}
}
});

How to create verified account during meteor seed

I have to create a verified account on seeding. The below user object creates user.email[0].verified = 'false' But it should be in true.
user = {
name: 'Admin',
email: 'admin#example.com',
password: 'password',
}
Meteor.startup(function() {
if (Meteor.users.find().count() < 2) {
Accounts.createUser(user); // It create user verification as false. How to make them true
}
});
I tried the below object but no use.
user = {
name: 'Admin',
email: [address:'admin#example.com',verified:true],
password: 'password',
}
Meteor packages:
accounts-password
ian:accounts-ui-bootstrap-3
It seems that Accounts.addEmail allows to programatically set the verified property. According to the documentation it should overwrite these settings if the user already has that email registered. Worth giving it a try
Accounts.addEmail(userId, newEmail, [verified])
http://docs.meteor.com/#/full/Accounts-addEmail
In your case (on the server):
user = {
name: 'Admin',
email: 'admin#example.com',
password: 'password',
}
Meteor.startup(function() {
if (Meteor.users.find().count() < 2) {
userId = Accounts.createUser(user);
Accounts.addEmail(userId, user.email, true);
}
});

Resources