javascript - 如何在 reactJS 中使用 emailJS 向特定用户发送电子邮件
问题描述
我想向在我的 react 网站上发货的特定用户发送报价。我正在使用 emailjs,但它似乎不起作用。我想要一种非服务器端的方式来做到这一点。
这是我的代码:
const {freight, creatorsEmail} = useLocation().state; //creatoresEmail is the email of the user i want to send the email to.
function sendEmail(e){
e.preventDefault()
emailjs.sendForm(
"xxxxx",
"xxxxxx",
creatorsEmail,
"xxxxx"
).then((res) => {
if(res){
firebase.firestore().collection("Quotations").add({
costPrice:costPrice,
sellPrice:sellPrice,
creatorsEmail:creatorsEmail,
freight:freight
}).then((result) => {
alert("Quotation Sent Successfully")
window.location.reload()
}).catch((e) => {
alert("An Error Occured, Quotation Cannot be Sent")
console.log(e)
})
}
}).catch((e) => {
alert("There was a problem")
console.log(e)
})
}
<Button
color="primary"
variant="contained"
onclick={sendEmail} // in here would this be a correct way of calling the function sendEmail(e)?
>
Send Quotation
</Button>
解决方案
推荐阅读
- java - 如何通过电子邮件发送文件而不先使用spring boot将其存储在存储中?
- java - keycloak 重定向以更新密码 url “login-actions/required-action”
- android - Kotlin Coroutines:作业调度问题。(invokeOnCompletion)
- python - 当我运行 Python 脚本在 Linux ['Firefox'] 中打开网站时出现错误
- javascript - 按日期对 desc 进行排序,如果并列则按 javascript 数组中的风险排序
- python - 使用“可选键”创建字典
- python - 如何将坐标捕捉到道路并计算距离
- java - 如何使用 spring webflux 以反应方式读取 JSON 文件?
- c++ - 如何使用 C++ 仅为 Open/Microsoft MPI 中的某些进程创建关键部分?
- kotlin - Kotlin:我如何检查应用程序是否已经打开过一次?