Emails not being sent (with no errors)
opened this issue · comments
Hello Doc,
I'm having bad time figuring out, because it was working at some point. No errors and there is a doc on Mongo !
Also there is something I think strange about the queue, one is in past (to be sent, so normally in future ?)
Thanks a lot Doc @dr-dimitru
I'm trying to catch any error possible
try {
mailQueue.sendMail({ to, subject, text, html }, function (err, info) {
if (err) {
console.log(err.message)
} else {
console.log(info)
}
})
} catch (error) {
console.log(error)
}
So is my callback fine ? and at instantiation, how to log errors ?
const client = await MongoClient.connect(mongoURL)
const db = client.db(dbName)
const transports = []
// Mailhog SMTP
transports.push(nodemailer.createTransport(config('SMTP_MAILHOG')))
// Outlook Apps SMTP
transports.push(nodemailer.createTransport(config('SMTP_OUTLOOK')))
const mailQueue = new MailTime({
db, // MongoDB
type: 'server',
strategy: 'backup', // Transports will be used in round robin chain
transports,
from(transport) {
// To pass spam-filters `from` field should be correctly set
// for each transport, check `transport` object for more options
return '"Classified ads" <' + transport.options.from + '>'
},
concatEmails: true, // Concatenate emails to the same addressee
concatDelimiter: '<h1>{{{subject}}}</h1>', // Start each concatenated email with it's own subject
template: MailTime.Template, // Use default template
revolvingInterval: 1000,
interval: 10
})
update
Trying Nodemailer and sending from Outlook to Gmail, at least the email is being sent (but blocked, I'll see what's next later)
import nodemailer from 'nodemailer'
const transporter = nodemailer.createTransport({
host: 'smtp.office365.com',
from: 'no-reply@classified-ads.com',
port: 587,
tls: {
ciphers: 'SSLv3',
},
secure: false,
auth: {
user: 'no_leak@live.Fr',
pass: 'no_leak_password',
},
})
// verify connection configuration
transporter.verify(function (error, success) {
if (error) {
console.log(error)
} else {
console.log('Server is ready to take our messages')
}
})
transporter.sendMail(
{
to: 'no_leak_2@gmail.com',
subject: "You've got an email!",
text: 'Plain text message',
html: '<h1>HTML</h1><p>Styled message</p>',
},
function (err) {
if (err) {
// check if htmlstream is still open and close it to clean up
}
},
)
Hello @bacloud22
- Regarding your screenshots, all looks good, the email just failed to send
- For debugging — pass
{debug: true}
intonew MailTime
constructor - I'd make sure sending works directly from NodeMailer's transports in the first place
Let me know if that helps in any way
Thanks Doc,
I had to change from
email address which was no-reply@classified-ads.com
to the actual email used to send.
I believe Outlook SMTP servers don't accept different emails like that.
problem solved 🥇