After reading some posts, I don't know why this meteor code fails to send the email to my own email address. Any idea is most appreciated.
//server.main.js
import { Email } from 'meteor/email'
smtp = {
username: 'my@gmail.com',
password: 'pass',
server: 'smtp.gmail.com',
port: '465'
};
process.env.MAIL_URL = 'smtp://' + encodeURIComponent(smtp.username) + ':' + encodeURIComponent(smtp.password) + '@' + encodeURIComponent(smtp.server) + ':' + smtp.port;
//then inside a method call
Testimonies.insert(testamonyObj, function(err, res) {
if (!err) {
let add = 'myAdd@gmail.com'
let mess = 'alosh bel awee'
Email.send({ add, add, res, mess });
}
Well, the options object you are passing to Email.send
just doesn't contain the necessary fields, most notably the to
field, see
https://docs.meteor.com/api/email.html#Email-send. Your current objects contains only three fields add
, res
, and mess
, none of which are valid field names understood by the send
function.
Try this:
Email.send({
to: add,
from: add,
subject: res,
text: mess
});