Hello, guys today, I'll be showing you how to create a Contact Form that allows users to submit and you receive a mail directly to Email Account
...
For further actions, you may consider blocking this person and/or reporting abuse
I tried this but I keep getting the internal error message. I think this is as a result of mailgun's rules whereby unless my credit card details are provided I won't be able to access their services and frankly Nigeria don't do credit cards so I can't access it.
Your debit card should work. Perhaps, you won't be charged unless you use up your free trial. Make sure you have the right mailgun domain and apiKey.
Oh, I stay in Nigeria too.
Any reason why mailgun is been used? Is there any difference using the mailgun with nodemailer and sending emails without mailgun with just nodemailer alone? Thanks.
The big deal here is SMTP protocol and Mailgun API.
Nodemailer provides a standard interface for sending both text and HTML-based emails.
Based on the
mailgun-js module
and thenodemailer module
, the Mailgun Transport was born. This is a transport layer, meaning it will allow you to send emails using nodemailer, using the Mailgun API instead of the SMTP protocol!Nodemailer allows you to write code once and then swap out the transport so you can use different accounts on different providers. On top of that, it's a super solid way of sending emails quickly on your node app(s).
The Mailgun transport for nodemailer is great to use when SMTP is blocked on your server or you just prefer the reliability of the web api!
afaik, you need to export after the bracket
const sendMail = (name, email, subject, text, cb) => {
const mailOptions = {
sender: name,
from: email,
to: 'recipient@email.com',
subject: subject,
text: text
};
}
// Exporting the sendmail
module.exports = sendMail;
You're right but I already have those included inside the mailOptions.
In the full code for server.js, you did
res.status({ message: 'Email sent!!!' });
in theelse
block of the sendMail functionYes, that's when no error occurred.
not getting mail
Check if your mailGun domain and private key are correct. You also might be missing something. I don't know if you've fixed it by now.
I get one error that is RangeError: Maximum call stack size exceeded error
check your callback functions, something is wrong there. Just the instruction you'll get it working.