I am working with nodemailer to send email using custom SMTP server.
let transporter = nodemailer.createTransport({
host: 'my.smtp.host',
port: 587,
secure: false,
auth: {
user: 'user',
pass: 'password',
},
debug: true,
logger: true
})
let info = await transporter.sendMail({
from: from,
to: to,
subject: subject,
text: content,
html: content,
cc: cc,
bcc: bcc,
})
Following is the result of sendMail.
{
accepted: [
'to#to.com'
],
rejected: [],
envelopeTime: 39,
messageTime: 49,
messageSize: 1730,
response: '250 2.0.0 Ok: queued as 5513B432BE6',
envelope: {
from: 'from#from.com',
to: [
'to#to.com'
]
},
messageId: '<274421c8-1abd-4973-dd8e-f57285b46a70#from.com>'
}
And following is log message.
...
[2021-06-09 19:00:21] INFO [StdWZWNkAto] <1730 bytes encoded mime message (source size 1693 bytes)>
[2021-06-09 19:00:21] DEBUG [StdWZWNkAto] S: 250 2.0.0 Ok: queued as 5513B432BE6
[2021-06-09 19:00:21] DEBUG [StdWZWNkAto] Closing connection to the server using "end"
I already tested this SMTP server with other tools and it works correctly.
What's wrong?
Please help me.
Well, this means that nodemailer successfully send the email and now it is in the queue of your custom SMTP server, so you have to deal with it. For instance, sendmail allows to see the queue via mailq command and resend via sendmail -q (or sendmail -q -v for more information). If you need more details, you should provide info about your SMTP server.
Related
I am getting the below error while sending a mail Via Logstash email plugin ,
←[31mSomething happen while delivering an email {:exception=>#<Net::SMTPAuthenticationError: 504 5.7.4 Unrecognized authentication type
Below is my Logstash Confifuration for email plugin :
email {
from => "mymail#domain.com"
options => [ "smtpIporHost", "my ip",
"port", "25",
"userName", "mymail#domain.com",
"password", "password"
]
via => "smtp" # or pop or sendmail
subject => "Alert from Logstash"
body => "Here is the event line %{#message}"
htmlbody => "<h2></h2><br/><br/><h3>Full Event</h3><br/><br/><div align='center'>%{#message}</div>"
}
But when I use JAVA client (a java program) to send a mail, I am able to send a mail but cannot reciprocate with Logstash.
Am I missng any configuration ? to avoid the above error
I don't know what exactly email plugin version you are using in your logstash, but you should add:
authentication => "login"
I am trying to integrate Mandrill to send and receive emails in my application. I am doing the following from http://localhost:3000 -
Run following to add mandrill to meteor project -
meteor add wylio:mandrill
put the following in server startup -
Meteor.startup(function() {
return Meteor.Mandrill.config({
username: "mandrill-user-id#gmail.com",
key: "Valid API Key generated in Mandrill",
password: "Valid API Key generated in Mandrill",
});
});
Then call the following to send the email -
Meteor.Mandrill.send(
{ host: "smtp.mandrillapp.com"
, port: 587
, to: to//"customer#anydomain.com"
, from: from //"you#yourdomain.com"
, subject: "Mandrill knows Javascript!"
, body: "Hello from NodeJS!"
, authentication: "LOGIN"
, username: "username#gmail.com"//username
, password: "API Key from mandrill page"//password
}, function(err, result){
if(err){
console.log(err);
}
}
);
When I try sending the email, I get the following error -
Exception while invoking method 'sendQollMail' AuthError: Invalid login - 535 Authentication failed: Bad username / password
at Object.Future.wait (/Users/priyanka/.meteor/packages/meteor-tool/.1.0.40.1qwqep8++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:326:15)
at smtpSend (packages/email/email.js:91:1)
at Object.Email.send (packages/email/email.js:168:1)
at Object.Meteor.Mandrill.send (packages/wylio:mandrill/mandrill.js:12:1)
at Object.QollMailer.sendQollEmail (app/server/lib/QollMailer.js:58:21)
at [object Object].Meteor.methods.sendQollMail (app/server/lib/QollMailer.js:87:27)
at maybeAuditArgumentChecks (packages/ddp/livedata_server.js:1599:1)
at packages/ddp/livedata_server.js:648:1
at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
at packages/ddp/livedata_server.js:647:1
- - - - -
at SMTPClient._actionAUTHComplete (/Users/priyanka/.meteor/packages/email/.1.0.5.s8780m++os+web.browser+web.cordova/npm/node_modules/simplesmtp/lib/client.js:826:23)
at SMTPClient._onData (/Users/priyanka/.meteor/packages/email/.1.0.5.s8780m++os+web.browser+web.cordova/npm/node_modules/simplesmtp/lib/client.js:329:29)
at CleartextStream.emit (events.js:95:17)
at CleartextStream.<anonymous> (_stream_readable.js:764:14)
at CleartextStream.emit (events.js:92:17)
at emitReadable_ (_stream_readable.js:426:10)
at _stream_readable.js:419:7
at process._tickCallback (node.js:419:13)
Can you tell me what am I doing wrong here?
I was doing everything correct. Except that - sometimes back I had tried integrating with mailgun (or some other service). That required setting up following env variable -
process.env.MAIL_URL = 'smtp://username:password#host:port';
This was overriding the username/password in mandrill. Taking it out resolved the issue.
I am a noob to grunt and would like to start using it.
Here is my gruntfile:
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
devDir: 'dev/dir',
prodDir: 'prod/dir',
'sftp-deploy': {
prod: {
auth: {
host: 'server.com',
port: 22,
authKey: {
"username": "username1",
"password": "password2"
}
},
src: '<%=devDir%>',
dest: '/test/env/',
concurrency: 4,
progress: true
}
}
});
// load modules
grunt.loadNpmTasks('grunt-sftp-deploy');
// Default task(s).
grunt.registerTask('default', ['sftp-deploy']);
};
I am getting this error when i run 'grunt' in powershell:
Running "sftp-deploy:prod" (sftp-deploy) task
Logging in with username username1
Concurrency : 4
Fatal error: Connection :: error
What am I doing wrong?
thanks!
Ok, a few things to try... (sorry - a month late!)
run:
grunt sftp-deploy --verbose
This will give you a little more info regarding your error.
I solved my error after realising I couldn't create folders on my server, only upload files. So it might be worth testing that you can accomplish manually what your asking grunt to do.
Lastly, try moving your username / password into a .ftppass file
link [here] (https://www.npmjs.com/package/grunt-sftp-deploy)
I know that this question was already made in this post: Send email when error occurs in console command of Symfony2 app, but answers do not provide a complete solution to the problem at hand and I can't comment on original post.
I need to send a monolog error email in command. E-mail is correctly enqueued in a file spooler; unfortunately I'm forced to use a memory spool.
Strangely enough the code snipper provided to manually flush the spool does work for emails generated in my code, not for monolog.
Does anybody know why this is happening and wether it would be possible to use a memory spool?
config.yml:
# Swiftmailer Configuration
swiftmailer:
transport: %mailer_transport%
host: %mailer_host%
username: %mailer_user%
password: %mailer_password%
spool: { type: memory }
# Monolog Configuration
monolog:
channels: ["account.create"]
handlers:
account.create.group:
type: group
members: [account.create.streamed, account.create.buffered]
channels: [account.create]
account.create.streamed:
type: stream
path: %kernel.logs_dir%/accounts_creation.log
level: info
account.create.buffered:
type: buffer
handler: account.create.swift
account.create.swift:
type: swift_mailer
from_email: xxx#yyy.com
to_email: aaa#gmail.com
subject: 'An Error Occurred while managing zzz!'
level: critical
config_prod.yml:
monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: %kernel.logs_dir%/%kernel.environment%.log
level: debug
channels: [!account.create]
usage example:
try
{
//code that could block
}
catch(ManageUserBlockingExceptionInterface $e)
{
$exitCode = self::EXIT_CODE_ERROR_BLOCKING;
//le eccezioni bloccanti vengono loggate e non si conferma che
//il messaggio è stato utilizzato ma si termina la coda
if(!\is_null($this->logger))
{
$this->logger->crit($e->getMessage());
}
}
the logger is injected in service by dependency injection as a service:
...
<argument type="service" id="monolog.logger.account.create" on-invalid="null" />
...
and it works because critical errors are streamed in file log; but also email is created if swiftmailer is configured with a file spool.
Finally, the code to manually flush memory spool is as folllow:
protected function flushMailSpool()
{
$mailer = $this->container->get('mailer');
$spool = $mailer->getTransport()->getSpool();
$transport = $this->container->get('swiftmailer.transport.real');
$spool->flushQueue($transport);
}
it is called immediately after a service purposedly sends an email; I noticed that the same code, put in command and adapted to command environment i.e. $this->container becomes $this->getContainer() does not work, maybe due to a scope change?
I'm working on sending a notification email using Logstash if an error occurs.
I'm using the email plugin coming as part of logstash : http://logstash.net/docs/1.4.2/outputs/email
On checking the documentation the To address seems to be the only required field and it didn't work when i specified it to my gmail id : pjesudhas#gmail.com
Is it required to have any other mail server running in my system for this to work, if so what do i have to do. Please let me know your thoughts.
email{
options => [ "smtpIporHost", "smtp.gmail.com",
"port", "587",
"userName", "pjesudhas#gmail.com",
"password", "mypassword"
]
from => "pjesudhas#gmail.com"
subject => "Error status"
to => "pjesudhas#gmail.com"
body => "Here is the event line that occured: %{#message}"
htmlbody => "<h2>%{matchName}</h2><br/><br/><h3>Full Event</h3><br/><br/><div align='center'>%{#message}</div>"
}
I also tried including my gmail id settings based on reading a tutorial but it didn't work either,please help me on this.
Gmail SMTP requires the to and from addresses to use a specific format: <example#example.org>
Try
email{
options => [ "smtpIporHost", "smtp.gmail.com",
"port", "587",
"userName", "pjesudhas#gmail.com",
"password", "mypassword"
]
from => "<pjesudhas#gmail.com>"
subject => "Error status"
to => "<pjesudhas#gmail.com>"
body => "Here is the event line that occured: %{#message}"
htmlbody => "<h2>%{matchName}</h2><br/><br/><h3>Full Event</h3><br/><br/><div align='center'>%{#message}</div>"
}