Email messages can't be sent


#1

Hello,
I’ve been trying to send email messages but I’m having some issues. Meteor is always returning: "Exception while invoking method “send.Email” Error: self signed certificate in certificate chain
I have tried with mailgum and postmark but the outcome is always the same.
This is my code:


if (Meteor.isServer){
	Meteor.startup(function () {

		process.env.MAIL_URL='smtps://adress:password@smtp.mailgun.org:465';

	});   



	Meteor.methods({
 		'sendEmail': function(to,name,text ){
 			
 			this.unblock();

 			Email.send({
 				to:to,
 				from: 'no-reply@test.com',
 				subject:name,
 				text:text


 			});
 			
 		}


	})

}

Has anyone have any ideas of what I can do? Thanks!


#2

You didn’t mention it, but you replaced adress:password with your own credentials right?


#3

Yes, and the “@” of the adress was replaced by %40


#4

Try switching the protocol to smtp and the port to 587. What you have looks like it should work, as far as I recall, but we have ours set to smtp/587 and it’s working. Port 587 is what Mailgun recommends (http://blog.mailgun.com/25-465-587-what-port-should-i-use/)

There was some funny business with protocol and port matching a while ago. If this change doesn’t work, post back with the version of the email package that you’re using.


#5

I’ve tried and it doesn’t work either. I’m using the email version: 1.2.3

I don’t know if it may be usefull but this is the complete message of error:


I20170726-20:53:50.158(2)? Exception while invoking method 'sendEmail' Error: se
lf signed certificate in certificate chain
I20170726-20:53:50.160(2)?     at Object.Future.wait (C:\Users\Pablo Lopez\test3
\.meteor\local\build\programs\server\node_modules\fibers\future.js:449:15)
I20170726-20:53:50.162(2)?     at Mail._syncSendMail (packages\meteor.js:213:24)

I20170726-20:53:50.164(2)?     at smtpSend (packages\email.js:116:13)
I20170726-20:53:50.166(2)?     at Object.Email.send (packages\email.js:174:5)
I20170726-20:53:50.169(2)?     at [object Object].Meteor.methods.sendEmail (serv
er/email.js:24:11)
I20170726-20:53:50.171(2)?     at maybeAuditArgumentChecks (packages/ddp-server/
livedata_server.js:1768:12)
I20170726-20:53:50.173(2)?     at packages/ddp-server/livedata_server.js:719:19
I20170726-20:53:50.174(2)?     at [object Object]._.extend.withValue (packages\m
eteor.js:1126:17)
I20170726-20:53:50.175(2)?     at packages/ddp-server/livedata_server.js:717:46
I20170726-20:53:50.177(2)?     at [object Object]._.extend.withValue (packages\m
eteor.js:1126:17)
I20170726-20:53:50.179(2)?     - - - - -
I20170726-20:53:50.181(2)?     at Error (native)
I20170726-20:53:50.182(2)?     at TLSSocket.<anonymous> (_tls_wrap.js:1065:38)
I20170726-20:53:50.184(2)?     at emitNone (events.js:67:13)
I20170726-20:53:50.187(2)?     at TLSSocket.emit (events.js:166:7)
I20170726-20:53:50.188(2)?     at TLSSocket._init.ssl.onclienthello.ssl.oncertcb
.TLSSocket._finishInit (_tls_wrap.js:623:8)
I20170726-20:53:50.190(2)?     at TLSWrap.ssl.onclienthello.ssl.oncertcb.ssl.onn
ewsession.ssl.onhandshakedone (_tls_wrap.js:453:38)

Thank you very much


#6

@plopezh hi there
i’m having the same issue
did you manage to solve it ?
thanks


#7

No, I haven’t figured out yet… but I’ll let you know if I do !


#8

Hi, I actually made this work using port:2525 with smtp … it doesn’t work with smtps
And I had errors on both port:587 and port:465 either [Error: self signed certificate in certificate] or [Error: ECONNRESET] , with both smtp and smtps
I could not find a satisfying answer so far, but at least it works now. I hope this will help others.


#9

It works for me too! Thank you very much for your help :slight_smile:


#10

I know this is older & doesn’t exact address the issue with mailgun… However, if anyone else runs across an issue with not being able to send through their own SMTP server with a self signed cert, setting the MAIL_URL env variable like below will allow you to use SSL & not reject when using a self signed cert.

MAIL_URL=“smtps://:@myserver.net:465?tls.rejectUnauthorized=false”


#11

Thank you johnf!! This works in my app with Meteor 1.5 and my own mail server! :wink: