Parse server rest password receiving email problem - node.js

I'm trying to implement the rest Password in my application so to do that I have added an email adapter to my server, like:
var parseServer = new ParseServer({
...
verifyUserEmails: false,
emailVerifyTokenValidityDuration: 24 * 60 * 60,
preventLoginWithUnverifiedEmail: false,
emailAdapter: !hasSMTPInfo ? undefined : {
module: 'parse-smtp-template',
options: {
port: env.EMAIL_PORT,
host: env.EMAIL_HOST,
user: env.EMAIL_USER,
password: env.EMAIL_PASSWORD,
fromAddress: env.EMAIL_FROMADDRESS,
template: false,
templatePath: env.EMAIL_TEMPLATEPATH
}
},
Rq: I have used the documentation of parse server api email from [documentation][1]
then I have implement the code of flutter part like:
final user = User(null, null, email);
await user.requestPasswordReset().then((value) async {
print(value.statusCode);
AlertUtils.showSuccessDialog('Veuillez vérifier votre boîte de réception')
.then((_) => Get.toNamed('/login'));
}).catchError((err) {
onDone.call();
AlertUtils.showErrorDialog(err.message.toString());
});
my problem is the status of response is 200 so every thing are right but I can't get any emails of restarting pw.
[1]: https://www.npmjs.com/package/parse-smtp-template

Related

Storing new mail from my mailbox into database

I want to store my new mails into postgresql database.
this is my main code, i was expecting it to show the new mail in console, but it won't
import {
MailListener,
IMailObject,
IMailAttachment
} from "mail-listener-typescript";
const options = {
username: "xxx#gmail.com", // mail
password: "xxx", // pass
host: "imap.gmail.com", // host
port: 993, // imap port
tls: true, // tls
connTimeout: 10000, // Default by node-imap
authTimeout: 5000, // Default by node-imap,
debug: console.log(), // Or your custom function with only one incoming argument. Default: null
tlsOptions: { rejectUnauthorized: false },
mailbox: "INBOX", // mailbox to monitor
searchFilter: ["NEW"], // the search filter being used after an IDLE notification has been retrieved
},
};
const MailListenerTS = new MailListener(options);
MailListenerTS.start();
MailListenerTS.on("mail", async function (mail: IMailObject, seqno: any, attributes: any) {
if (mail.attachments.length > 0) {
var mailAttachments: IMailAttachment[] = []
for (let attachment of mail.attachments) {
mailAttachments.push(attachment)
}
let mailData ={
name: mail.from.value[0].name,
sender: mail.from.value[0].address,
date: new Date(mail.date),
files: mailAttachments
}
console.log(mailData)
}
});
and my tables are:
context: id, subject, message
user: id, email

Error: Invalid greeting. response=421 Service not available: 421 Service not available

i tried using nodemailer to send emails from my outlook account to other accounts but i keep getting this error.
Error: Invalid greeting. response=421 Service not available: 421 Service not available
code: 'EPROTOCOL',
response: '421 Service not available',
responseCode: 421,
command: 'CONN'
Here is my code
const nodemailer = require("nodemailer");
module.exports = function OTP() {
// Sends otp link to and code to user
return new Promise((resolve, reject) => {
const transporter = nodemailer.createTransport({
service: "hotmail",
port: "25",
secure: true,
auth: {
user: process.env.EMAIL, //Outlook email
pass: process.env.EMAIL_PASSWORD,
},
tls: {
ciphers: "SSLv3",
},
});
transporter.sendMail(
{
from: process.env.EMAIL,
to: email,
subject: "Test",
text: `
`,
},
(err, info) => {
if (err) {
console.log(err);
return reject({ message: "An error has occurred" });
} else return resolve({ message: "Email sent" });
}
);
});
};
i tried changing the port and switching to gmail but i get the same error.
I had this same error but in nestjs and this is my solution that you can try.
First in my configuration I did not define a port and my secure was set to false, so port was default to 587. I was sending mail and everything was fine untill one day I started to get the same error as you are getting now. so here is my fix
I use telnet to test my connection to the mail server:
a. Open terminal and type: telnet your_domain 587. eg
telnet smtp.sendgrid.net 587
I got 421 Service not available
I change secure to true which will now default the port to 465 and I try telnet again, this time
telnet smtp.sendgrid.net 465
I got no error. I test the endpoint again and everything works fine.
I hope this helps
Reference:
stackoverflow
nodemailersmtp

Send Email Using Microsoft 365 Email Server In NodeJS

let transporter = nodemailer.createTransport({
service: "Outlook365",
host: 'smtp.office365.com',
port: 587,
tls: {
ciphers:'SSLv3'
},
auth: {
user: 'username',
pass: 'password'
}
});
I have an EAUTH error while sending an email, please check the image for error.
[1]: https://i.stack.imgur.com/snt3T.jpg
This code should do what you wish, you'll need to set your password to test this.
If the password is incorrect, you'll get an error:
Error: Invalid login: 535 5.7.3 Authentication unsuccessful message.
const nodemailer = require('nodemailer');
// Set this from config or environment variable.
const PASSWORD = '....';
async function send365Email(from, to, subject, html, text) {
try {
const transportOptions = {
host: 'smtp.office365.com',
port: '587',
auth: { user: from, pass: PASSWORD },
secureConnection: true,
tls: { ciphers: 'SSLv3' }
};
const mailTransport = nodemailer.createTransport(transportOptions);
await mailTransport.sendMail({
from,
to,
replyTo: from,
subject,
html,
text
});
} catch (err) {
console.error(`send365Email: An error occurred:`, err);
}
}
send365Email("from#example.com", "to#example.com", "Subject", "<i>Hello World</i>", "Hello World");
You will need to disable the SmtpClientAuthenticationDisabled through the online power shell with the command
Set-TransportConfig -SmtpClientAuthenticationDisabled $false
You can check for more information at Enable or disable authenticated client SMTP submission (SMTP AUTH) in Exchange Online
You can find the detailed information here:
https://developer.microsoft.com/en-us/graph/quick-start?code=M.R3_BAY.822b5ade-d816-85bb-ec94-8c349cdfca4b&state=option-node

Emails sent from SMTP server hosted on hostmonster using nodemailer are not delivering to the recipients

Our SMTP server is hosted on hostmonster. We are using nodemailer to send emails from our app to the users. The problem I am facing is that, I am getting 250 OK response from the SMTP server but the emails don't get delivered to the users. I am using the exact email configurations provided by the hostmonster.
Our nodemailer configurations are:
var mailTransporter = nodemailer.createTransport({
host: "mail.domain.com",
port: 456,
secure: true,
auth: {
user: "account#domain.com",
pass: "password"
},
tls: {
rejectUnauthorized: false,
},
});
And the response I get:
{ accepted: [ 'email#domain.com' ],
rejected: [],
envelopeTime: 899,
messageTime: 315,
messageSize: 3464,
response: '250 OK id="someid"',
envelope:
{ from: 'account#domain.com',
to: [ 'email#domain.com' ] },
messageId: '<some-id#domain.com>' }
I expect the email to get delivered to the users (recipients) but it doesn't get delivered.
Could anyone of you please verify my nodemailer configurations? Is there any issue with my nodemailer configurations? or Could there be any issue on the hostmonster side?
Turned out, I need to add "name" option to the createTransport() configuration. The name should be the domain i.e. "www.domain.com".
var mailTransporter = nodemailer.createTransport({
name: "www.domain.com",
host: "mail.domain.com",
port: 456,
secure: true,
auth: {
user: "account#domain.com",
pass: "password"
},
tls: {
rejectUnauthorized: false,
},
});
Reference: https://github.com/nodemailer/nodemailer/issues/677

how to setup emailjs to send email

I am trying to use mailjs to send out email, and here is what I got:
var server = email.server.connect({
user: "something#mydomain.com",
password: "pw",
host: "smtp.office365.com",
port: "587",
tls: true
});
server.send({
text: "test!!",
from: "someemail#mydomain.com",
to: "recipient#somedomain.com",
subject: "hello"
}, function(err, message){console.log(err || message);});
The above code eventually throw me an error:
{ [Error: authorization.failed]
code: 3,
previous: { [Error: timedout while connecting to smtp server] code: 4, smtp: undefined },
smtp: undefined }
So basically my corporate email service is on office365, configured to use mydomain.com. I don't really know what does the user and password mean for the server, so I just used the sender's email and password. Is it anything wrong with my code? Maybe this is the problem?? Or otherwise what would it be?
First check and confirm host.Here is no need to use port: "587", tls: true.
You can use, this is wrking code
var server = email.server.connect({
user: 'abc#india.com',
password: 'vvq3tng$',
host: 'your host',
ssl: true,
});
server.send({
from: '<abc#india.com>', // sender address
to: '<xyz#india.com>',// list of receivers
cc: '',
subject: 'your subject', // Subject line
text: 'contant', // html body
}, function (err, message) {
if(err) {
console.log(err)
} else {
console.log("email sent")
}
});

Resources