Next.js Discord

Discord Forum

auto email : how

Unanswered
Cape lion posted this in #help-forum
Open in Discord
Cape lionOP
Hey all

i've been building web app using Nextjs.
And I was wondering how could i implement auto mailing feature not using third party api like of mail chimp.

when user fills up the form. I get their information in my database.
Do i have to make server components? or what else so that they receive the mail from my web app that their booking has been confirmed.

please provide me suggestions or resources on how can i acheive this.
thanks

31 Replies

American Chinchilla
I dont thinks thats possible
Also for security purposes it is better to use third party unless you know what your doing
Yeah, u should use third party. checkout Resend, it's pretty good
American Chinchilla
Yeah i use that one too *^
Some email third party libraries do require you use server components for security purposes also such as Resend (to be handle in server to hide api keys)
Other allow client side
Sun bear
it is possible, but you have to create a mailserver. I would buy a VPS and a domain, then use something like [docker mailserver](https://docker-mailserver.github.io/docker-mailserver/latest/) to set it up. Make sure you setup all the security like DMARC, DKIM, SPF so gmail, yahoo, microsoft can receive your emails.

Lastly use nodemailer or emailjs to send an email using SMTP.
resend is probably the best if you don't want to spend a few days learning SMTP and other boring stuff.
@American Chinchilla This question has been answered here too https://www.reddit.com/r/nextjs/comments/tgwg5f/how_to_add_a_contact_form_without_thirdparty/
Cape lionOP
thanks @American Chinchilla for providing me the resources about the similar topic and your insights
@averydelusionalperson Yeah, u should use third party. checkout Resend, it's pretty good
Cape lionOP
thanks @averydelusionalperson for your insights
by checkout resend you mean this one?
https://docs.affirm.com/developers/reference/resend_checkout-1

please correct me
Sun bear
no
the issue with getting cheap is that they will have the worst Ip reputation and get insta spammed (ik this because i am curretly trying to deal with it) - but if users are willing to go to the spam folder its pretty cool
@Cape lion <@696792098996879379> which VPS is good for starter? if free best or if cheap its good too
Sun bear
I use hetzner, but you have to pay the first month to enable SMTP. I am paying $3.5/mo, no issues sending or receiveing emails.
it's the cheapest I've found and so far they are really reliable
@Sun bear I use hetzner, but you have to pay the first month to enable SMTP. I am paying $3.5/mo, no issues sending or receiveing emails.
that actually sounds good, as if you have to manually apply for it, then way easier to get liked :)

do you have any other things on this vps, or just email server 👀
Sun bear
I am hosting a next.js storefront, express server (for store backend), postgres (for my store project), redis (and mailserver). The only problem is the website get's slow if there are like 5 people on it at the same time (for 1 user it works great), but I use this only as a demo for my storefront so it's not a problem. never had any issues with the mailserver.
American Chinchilla
Hmm even on a demo it shouldnt be slow for that many people unless there extra network request or other issues.
i think its just not able to parallel
American Chinchilla
Oh okay thx yeah i remember now express.js is single thread unless other modules used for parallelism.
Sun bear
yes, 5 people sending requests every 200ms
i tested this using postman
but you shouldn't have this problem if you are only hosting mailserver
I was really testing the limits of it with 2 next.js applications, express server, postgres, redis and mailserver at the same time on 4GB ram.
@Sun bear but you shouldn't have this problem if you are only hosting mailserver
Cape lionOP
U hosted your web app too there ?
And also mail server?
Sun bear
yes
for $3.5/mo