我对angulardart很陌生,我正在研究mailer,但是我遇到了一个错误,上面写着:
dart_sdk.js:100398异常:不支持的操作: Platform._localHostname STACKTRACE: dart:sdk_internal 获取localHostname包:mailer2 2/src/smtp/smtp_options.dart 4:25 新软件包:mailer2 2/src/smtp/helper_options.dart 12:24 新package:DigitalHrSummit/src/components/homepagecomponent/homepage_component.dart 68:21 onSubmit package:DigitalHrSummit/src/components/homepagecomponent/homepage_component.template.dart 1025:8 _handle_click_287_包:_handle_click_287_/src/core/linker/app_view.dart 602:29 src__core__linker__app_view_utils.appViewUtils.eventManager.zone.runGuarded.dart.fn包:角/src/核/区/ng_zone.dart 134:16 parent.run.dart.fn dart:sdk_internal 运行包:角/src/核心/区域/ng_zone.dart 131:18 _run dart:sdk_internal runGuarded包:角/src/核心/区域/ng_zone.DART 302:22 runGuarded包:角/src/core/linker/app_view.dart 601:37 事件
基本上,我只有可以找到这里的示例代码。我的gmail用户名和密码在选项变量中。
我的.dart组件(homepage_component.dart)中有示例代码
...
import 'package:mailer2/mailer.dart';
...
class HomeComponent(){
void onSubmit(Map<String, dynamic> contactUsInfo) {
//Gmail account used to send email
var options = new GmailSmtpOptions()
..username = 'my-gmail-account'
..password = 'my-gmail-password';
// Create our email transport.
var emailTransport = new SmtpTransport(options);
// Create our mail/envelope.
var envelope = new Envelope()
..from = 'sender-email-here'
..recipients.add('recievers-mail-here')
//..bccRecipients.add('hidden@recipient.com')
..subject = 'Testing the Dart Mailer library'
//..attachments.add(new Attachment(file: new File('path/to/file')))
..text = 'This is a cool email message. Whats up?'
..html = '<h1>Test</h1><p>Hey!</p>';
// Email it.
emailTransport.send(envelope)
.then((envelope) => print('Email sent!'))
.catchError((e) => print('Error occurred: $e'));
}
}请帮帮我伙计们。谢谢。
发布于 2019-03-05 23:01:14
这个库dart:io,因此它不能在网络上使用。
https://stackoverflow.com/questions/55007501
复制相似问题