DEV Community

Discussion on: Send mails using NodeJS

Collapse
suchitra_13 profile image
Suchitra

Thank you so much.
But I am facing difficulty in attachment sending part, I have tried 3 times but couldn't send only text sent!

Collapse
drsimplegraffiti profile image
Abayomi Ogunnusi Author

@Suchitra

Do you have a folder where your image is stored?

Example:

attachment: [{
filename: "robocop.jpg", path: "./img/robocop.jpg"}]
};

Collapse
suchitra_13 profile image
Suchitra

I kept image file in same folder where my index.js is present.
So in this case I just wrote:

attachment: [{
filename: "robocop.jpg", path: "robocop.jpg"}]
};

But it is not working:(

Thread Thread
horomancer profile image
horomancer

shouldn't it be

path: "./robocop.jpg"
Enter fullscreen mode Exit fullscreen mode
Collapse
jlong4223 profile image
Jared Long

@Suchitra try adding an 's' to attachment: attachments: [{

I ran into the same thing with just text showing up and checked the nodemailer documentation on attachements. That little mispelling fix should do the trick.

Also, if you want to learn how to do this with a React frontend and Google OAuth2, check out my nodemailer article as well :)

Collapse
suchitra_13 profile image
Suchitra

Thank you so much
It's working fine now:)