Meteor email.send() from field purpose - javascript

Why does the Email.send() function from the email package contain a 'from' argument if every email will be sent from the email defined in your process.env.MAIL_URL environmental variable?
Server-side code:
process.env.MAIL_URL = 'smtp://my_email%40gmail.com:my_password#smtp.gmail.com:465/'
Meteor.methods({
sendEmail: function (to, from, subject, text) {
check([to, from, subject, text], [String]);
// Let other method calls from the same client start running,
// without waiting for the email sending to complete.
this.unblock();
Email.send({
to: to,
from: from,
subject: subject,
text: text
});
}
});
Client-side Code:
Meteor.call('sendEmail',
my_email#email.com,
email,
name,
message);
where email, name, and message are variables that are read from form elements.

In your case, when sending through a Gmail account, you are correct. The from email address must match the email address associated with the login information. However, when sending through an SMTP relay service, like Amazons SES or MailChimp, it is possible to set the from address to any verified email address or domain, so you can send from multiple email addresses.

Related

Difference between firebase auth verifyBeforeUpdateEmail and updateEmail

You can use updateEmail with the following workflow:
await user.updateEmail(newEmail)
await user.getIdToken()
await user.sendEmailVerification()
and there's also a function verifyBeforeUpdateEmail.
These two workflows seems identical to me, but is there any difference?
The documentation lacks examples and explanations of the difference.
Reference: https://firebase.google.com/docs/reference/js/firebase.User#verifybeforeupdateemail
The User.verifyBeforeUpdateEmail method is documented as:
Sends a verification email to a new email address. The user's email will be updated to the new one after being verified.
So the process here sends a verification email to the new email address. Only once the user clicks the link in that email will their email address be updated and the emailVerified property of their account set to true.
The user.updateEmail method is documented as:
Updates the user's email address.
So when you use updateEmail, the user's email address ends up being unverified. If you care about email verification, you'll need to call sendEmailVerification again to verify the updates email address. But even if you call sendEmailVerification right after updating the email address, the user account will have its emailVerified property set fo false for a while.

Nodemailer not sending email

I just set up my glitch project with a contact form and im trying to get it to send an email to me when someone fills out the form. The issue that I am having is that the server logs in console that the message has been sent with no errors but I never receive the email. You can find the code at https://glitch.com/edit/#!/gamesalt-dev?path=packages%2FPOSTroutes.js%3A2%3A39 and the contact form can be found at https://gamesalt-dev.glitch.me/.
let account = {
user: "some.name#ethereal.email",
pass: "************"
}
let transporter = nodemailer.createTransport({
host: "smtp.ethereal.email",
port: 587,
secure: false,
auth: {
user: account.user,
pass: account.pass,
},
});
let mailOptions = {
from: `"Contact" <${account.user}>`,
to: "some.name#example.com",
subject: "New Contact!",
text: "Hello world",
html: "<b>Hello world</b>",
}
let info = await transporter.sendMail(mailOptions, (error, info) => {
if(error) return console.log(error);
console.log("Message sent: %s", info.messageId);
console.log("Preview URL: %s", nodemailer.getTestMessageUrl(info));
});
http://ethereal.email/
Ethereal is a fake SMTP service, mostly aimed at Nodemailer users (but not limited to). It's a completely free anti-transactional email service where messages never get delivered.
Instead, you can generate a vanity email account right from Nodemailer, send an email using that account just as you would with any other SMTP provider and finally preview the sent message here as no emails are actually delivered.
Even if not, the server logs in console that the message has been sent with no errors the message you get is that the SMTP server successfully accepted your mail and added it to the send queue, but that will not guarantee that it will be delivered. The receiving SMTP server could still reject it and send a bounce message back.

Get user's Info from post request of Nodemailer

i am using for our project in company the nodemailer, its working perfectly
fine.
I am wondering if its possible to get user's info automatically from the post request. for example i need to get the html variable like this:
html: 'Hello i am ${request.username} i sent this email to you'
this is how i need my request looks like:
var transporter = nodemailer.createTransport({
host: 'servername.com',
port: 25,
debug: true,
logger:true,
secure: false,
});
// i need the mail options like the following
var mailOptions = {
from: 'MYEMAIL#COMPANYNAME.com', // sender address (who sends)
to: 'MYEMAIL#COMPANYNAME.com', // list of receivers (who receives)
subject: 'this email sent from ${request.username} ', // Subject line
text: 'Hello world ', // plaintext body
html: 'this email sent from ${request.username}'
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
What you are asking is not possible (atleast ethically) unless you have username and email mapping available. But still to add a personal touch to email you can use part before "#" i.e. take this email for instance "your_name#domain.com", you can send email as
${request.username} will be "your_name"

Verify an email account is active using react on the *client side*

I am making an authentication form and I would like to verify silently an email address is active on the client side. That is if the email address exists, then return true, else return false. This does not involve sending an actualy email to the address. I can do this on the server side using email-verify package in node, ie:
server.post('/api/verify-valid-email-silently', (req, res) => {
if (req.body && req.body.email) {
const email = req.body.email
email_verifier.verify( email, (err : string, info : any) => {
// do something
})
}
}
But I would like to do this on the client side so that I don't have to ping the server and pay for cloud function invocation. Again I'm looking for a free service on the client side. This is important because if I use the current "ping the server" way, someone could conceivably repeatedly enter inactive but well-formed email address and drain my bank account dry completely.
It does require a validation email, but it can be done without maintaining server-side infrastructure. I actually built a platform to do exactly that at https://clicktoverify.net/.
Essentially you just need to add our (small) javascript library to your page. Then you'll be able to send a verification email via our service and execute a client-side callback once the client verifies by clicking the link in their email.

How to customize sender for Meteor Accounts' password reset mail

How can I customize the sender for password reset mail sent by Meteor Accounts?
The sender used by Meteor Accounts when sending password reset mail is controlled by the Accounts.emailTemplates.sender attribute. Just assign your desired value to it on server startup, for example:
Meteor.startup(function () {
Accounts.emailTemplates.from = "Admin <no-reply#example.com>"
})

Categories

Resources