0
votes

I am new to angulardart and I am working on mailer, but I am having an error that says:

dart_sdk.js:100398 EXCEPTION: Unsupported operation: Platform._localHostname STACKTRACE: dart:sdk_internal
get localHostname package:mailer2/src/smtp/smtp_options.dart 4:25
new package:mailer2/src/smtp/helper_options.dart 12:24
new 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_0] package:angular/src/core/linker/app_view.dart 602:29
src__core__linker__app_view_utils.appViewUtils.eventManager.zone.runGuarded.dart.fn package:angular/src/core/zone/ng_zone.dart 134:16
parent.run.dart.fn dart:sdk_internal
run package:angular/src/core/zone/ng_zone.dart 131:18
[_run] dart:sdk_internal
runGuarded package:angular/src/core/zone/ng_zone.dart 302:22
runGuarded package:angular/src/core/linker/app_view.dart 601:37
event

Basically I just have the sample code that can be found here . I have my gmail username and password in the options variable.

I have the sample code inside my .dart component(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('[email protected]')
    ..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'));



  }
}

Please help me guys. Thank you.

1

1 Answers

1
votes

This library imports dart:io and therefore it isn't usable on the web.