为什么“email_sender”在此 Web 应用程序项目中未激活?

问题描述 投票:0回答:1

包:email_sender firebase 使用:是

我想在我的项目中使用发件人电子邮件,因此包“flutter_email_sender”不起作用,因为它不适用于网络应用程序,然后我尝试另一个包“email_sender”,它用于网络应用程序项目,我尝试了但它得到了像这样的“somethingWrong”错误

------------图片错误------------------------ enter image description here ------------图片错误------------------------

-------------sent1() 函数------------------------

import 'package:email_sender/email_sender.dart';

 void sent1() async {
    EmailSender emailsender = EmailSender();
    var response =
        await emailsender.sendMessage("[email protected]", "a", "b", "c");
    print(response["message"]);
  }

-------------sent1() 函数------------------------

------------ 我想将sent1() 放入的FloatingActionButton--------------------

Container(
              height: size.height * 0.08,
              width: size.width * 0.2,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(16),
                color: Colors.blue[200],
              ),
              child: FloatingActionButton(
                onPressed: () async {
                  if (formKey.currentState!.validate() &&
                      selectedValue1 == "ซินเนติก") {
                    formKey.currentState?.save();
                    try {
                      String invoiceNumber = await generateInvoiceNumber();
                      await _prdetailsCollection.add({
                        "project": selectedValue4,
                        "dropdowncompany": selectedValue1,
                        "dropdowndep": selectedValue2,
                        "dropdownwork": selectedValue3,
                        "fsname": prdetails.fsnames,
                        "date_pr": _dateController.text,
                        "recommend_company": prdetails.recommendcompanypr,
                        "phone": prdetails.phones,
                        "email_pr": prdetails.emailprs,
                        "number1": tablePR1.n1,
                        "order1": tablePR1.o1,
                        "des1": tablePR1.d1,
                        "amount1": tablePR1.a1,
                        "unit1": tablePR1.u1,
                        "additonal1": tablePR1.add1,
                        "number2": tablePR2.n2,
                        "order2": tablePR2.o2,
                        "des2": tablePR2.d2,
                        "amount2": tablePR2.a2,
                        "unit2": tablePR2.u2,
                        "additonal2": tablePR2.add2,
                        "number3": tablePR3.n3,
                        "order3": tablePR3.o3,
                        "des3": tablePR3.d3,
                        "amount3": tablePR3.a3,
                        "unit3": tablePR3.u3,
                        "additonal3": tablePR3.add3,
                        "number4": tablePR4.n4,
                        "order4": tablePR4.o4,
                        "des4": tablePR4.d4,
                        "amount4": tablePR4.a4,
                        "unit4": tablePR4.u4,
                        "additonal4": tablePR4.add4,
                        "number5": tablePR5.n5,
                        "order5": tablePR5.o5,
                        "des5": tablePR5.d5,
                        "amount5": tablePR5.a5,
                        "unit5": tablePR5.u5,
                        "additonal5": tablePR5.add5,
                        "number6": tablePR6.n6,
                        "order6": tablePR6.o6,
                        "des6": tablePR6.d6,
                        "amount6": tablePR6.a6,
                        "unit6": tablePR6.u6,
                        "additonal6": tablePR6.add6,
                        "number7": tablePR7.n7,
                        "order7": tablePR7.o7,
                        "des7": tablePR7.d7,
                        "amount7": tablePR7.a7,
                        "unit7": tablePR7.u7,
                        "additonal7": tablePR7.add7,
                        "number8": tablePR8.n8,
                        "order8": tablePR8.o8,
                        "des8": tablePR8.d8,
                        "amount8": tablePR8.a8,
                        "unit8": tablePR8.u8,
                        "additonal8": tablePR8.add8,
                        "number9": tablePR9.n9,
                        "order9": tablePR9.o9,
                        "des9": tablePR9.d9,
                        "amount9": tablePR9.a9,
                        "unit9": tablePR9.u9,
                        "additonal9": tablePR9.add9,
                        "number10": tablePR10.n10,
                        "order10": tablePR10.o10,
                        "des10": tablePR10.d10,
                        "amount10": tablePR10.a10,
                        "unit10": tablePR10.u10,
                        "additonal10": tablePR10.add10,
                        "scale1": tablePR1.scale1,
                        "scale2": tablePR2.scale2,
                        "scale3": tablePR3.scale3,
                        "scale4": tablePR4.scale4,
                        "scale5": tablePR5.scale5,
                        "scale6": tablePR6.scale6,
                        "scale7": tablePR7.scale7,
                        "scale8": tablePR8.scale8,
                        "scale9": tablePR9.scale9,
                        "scale10": tablePR10.scale10,
                        "สิ้นเปลือง": isChecked1,
                        "อุปกรณ์-เครื่องมือ": isChecked2,
                        "วัตถุดิบเพื่อการขาย": isChecked3,
                        "วัตถุดิบเพื่อการซ่อมแซม": isChecked4,
                        "วัตถุดิบเพื่อการผลิต": isChecked5,
                        "purchase_req": invoiceNumber,
                        "price1": tablePR1.price1,
                        "price2": tablePR2.price2,
                        "price3": tablePR3.price3,
                        "price4": tablePR4.price4,
                        "price5": tablePR5.price5,
                        "price6": tablePR6.price6,
                        "price7": tablePR7.price7,
                        "price8": tablePR8.price8,
                        "price9": tablePR9.price9,
                        "price10": tablePR10.price10,
                      }).then((value) {
                        sent1();
                        formKey.currentState?.reset();
                        Fluttertoast.showToast(
                          msg: "Submitted",
                          gravity: ToastGravity.CENTER,
                        );
                        Navigator.pushReplacement(context,
                            MaterialPageRoute(builder: (context) {
                          return PipelinePurchase();
                        }));
                      });
                    } catch (e) {}
                  } else if (formKey.currentState!.validate() &&
                      selectedValue1 == "ซินโนวิค") {
                    formKey.currentState?.save();
                    try {
                      String invoiceNumber1 = await generateInvoiceNumber1();
                      await _prdetailsCollection.add({
                        "project": selectedValue4,
                        "dropdowncompany": selectedValue1,
                        "dropdowndep": selectedValue2,
                        "dropdownwork": selectedValue3,
                        "fsname": prdetails.fsnames,
                        "date_pr": _dateController.text,
                        "recommend_company": prdetails.recommendcompanypr,
                        "phone": prdetails.phones,
                        "email_pr": prdetails.emailprs,
                        "number1": tablePR1.n1,
                        "order1": tablePR1.o1,
                        "des1": tablePR1.d1,
                        "amount1": tablePR1.a1,
                        "unit1": tablePR1.u1,
                        "additonal1": tablePR1.add1,
                        "number2": tablePR2.n2,
                        "order2": tablePR2.o2,
                        "des2": tablePR2.d2,
                        "amount2": tablePR2.a2,
                        "unit2": tablePR2.u2,
                        "additonal2": tablePR2.add2,
                        "number3": tablePR3.n3,
                        "order3": tablePR3.o3,
                        "des3": tablePR3.d3,
                        "amount3": tablePR3.a3,
                        "unit3": tablePR3.u3,
                        "additonal3": tablePR3.add3,
                        "number4": tablePR4.n4,
                        "order4": tablePR4.o4,
                        "des4": tablePR4.d4,
                        "amount4": tablePR4.a4,
                        "unit4": tablePR4.u4,
                        "additonal4": tablePR4.add4,
                        "number5": tablePR5.n5,
                        "order5": tablePR5.o5,
                        "des5": tablePR5.d5,
                        "amount5": tablePR5.a5,
                        "unit5": tablePR5.u5,
                        "additonal5": tablePR5.add5,
                        "number6": tablePR6.n6,
                        "order6": tablePR6.o6,
                        "des6": tablePR6.d6,
                        "amount6": tablePR6.a6,
                        "unit6": tablePR6.u6,
                        "additonal6": tablePR6.add6,
                        "number7": tablePR7.n7,
                        "order7": tablePR7.o7,
                        "des7": tablePR7.d7,
                        "amount7": tablePR7.a7,
                        "unit7": tablePR7.u7,
                        "additonal7": tablePR7.add7,
                        "number8": tablePR8.n8,
                        "order8": tablePR8.o8,
                        "des8": tablePR8.d8,
                        "amount8": tablePR8.a8,
                        "unit8": tablePR8.u8,
                        "additonal8": tablePR8.add8,
                        "number9": tablePR9.n9,
                        "order9": tablePR9.o9,
                        "des9": tablePR9.d9,
                        "amount9": tablePR9.a9,
                        "unit9": tablePR9.u9,
                        "additonal9": tablePR9.add9,
                        "number10": tablePR10.n10,
                        "order10": tablePR10.o10,
                        "des10": tablePR10.d10,
                        "amount10": tablePR10.a10,
                        "unit10": tablePR10.u10,
                        "additonal10": tablePR10.add10,
                        "scale1": tablePR1.scale1,
                        "scale2": tablePR2.scale2,
                        "scale3": tablePR3.scale3,
                        "scale4": tablePR4.scale4,
                        "scale5": tablePR5.scale5,
                        "scale6": tablePR6.scale6,
                        "scale7": tablePR7.scale7,
                        "scale8": tablePR8.scale8,
                        "scale9": tablePR9.scale9,
                        "scale10": tablePR10.scale10,
                        "สิ้นเปลือง": isChecked1,
                        "อุปกรณ์-เครื่องมือ": isChecked2,
                        "วัตถุดิบเพื่อการขาย": isChecked3,
                        "วัตถุดิบเพื่อการซ่อมแซม": isChecked4,
                        "วัตถุดิบเพื่อการผลิต": isChecked5,
                        "purchase_req": invoiceNumber1,
                        "price1": tablePR1.price1,
                        "price2": tablePR2.price2,
                        "price3": tablePR3.price3,
                        "price4": tablePR4.price4,
                        "price5": tablePR5.price5,
                        "price6": tablePR6.price6,
                        "price7": tablePR7.price7,
                        "price8": tablePR8.price8,
                        "price9": tablePR9.price9,
                        "price10": tablePR10.price10,
                      }).then((value) {
                        sent1();
                        formKey.currentState?.reset();
                        Fluttertoast.showToast(
                          msg: "Submitted",
                          gravity: ToastGravity.CENTER,
                        );
                        Navigator.pushReplacement(context,
                            MaterialPageRoute(builder: (context) {
                          return PipelinePurchase();
                        }));
                      });
                    } catch (e) {}
                  }
                },
                backgroundColor: Colors.blueAccent[200],
                child: Text(
                  "Submit Form",
                  style: kBodyText,
                ),
              ),
            ),

------------ 我想将sent1() 放入的FloatingActionButton--------------------

那么为什么 email_sender 不起作用,有人尝试这个 email_sender 吗?或者谁有其他方法在 flutter web 应用程序中发送电子邮件?

flutter firebase dart email flutter-dependencies
1个回答
0
投票

如果没有配置 SMTP 服务器或没有某种类型的帐户(例如 Firebase),您将找不到发送电子邮件的包。

如果您的应用程序可以像那样发送电子邮件,那将是垃圾邮件发送者的梦想。

我不确定是否可以通过浏览器连接到电子邮件服务器。通常,您连接到后端,后端会发送一封邮件,因为它能够更好地处理任何后果,并且假设您不希望用户在您的应用程序中输入自己的凭据,那么那里的凭据也更安全.

© www.soinside.com 2019 - 2024. All rights reserved.