Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Unsupported operation: RawSocket constructor #203

Closed
Patrick386 opened this issue Feb 9, 2022 · 3 comments
Closed

Error: Unsupported operation: RawSocket constructor #203

Patrick386 opened this issue Feb 9, 2022 · 3 comments

Comments

@Patrick386
Copy link

Patrick386 commented Feb 9, 2022

I use Google Workspace and have an account.
Also, I'm using the FlutterFire UI.

I got the mail and token normally.
An error occurred as below.
Could you please tell me what settings I need?

Flutter Web
Error: Unsupported operation: RawSocket constructor

Code:

  sendEmail(UserModel prontoUser) async {
    final String userEmail =  'milke.${prontoUser.email}';     
    final String accessToken = prontoUser.accessToken;

    final smtpServer = gmailSaslXoauth2(userEmail, accessToken);

    print('email:${userEmail}  - ${accessToken}');
    final message = Message()
      ..from = Address(userEmail, 'Pronto Io')
      ..recipients = [userEmail]
      ..subject = 'Hello ellisvill'
      ..text = 'This is a test email!';

    print('message:$userEmail  ${accessToken}');

    await send(message, smtpServer);

    ToastMsg(message: 'Success Send email!', msgType: MsgType.success);
  }
message:milke.patrick386@sint.kr  eyJhbGciOiJSU......

Error: Unsupported operation: RawSocket constructor
    at Object.throw_ [as throw] (http://localhost:51944/dart_sdk.js:5067:11)
    at Function.connect (http://localhost:51944/dart_sdk.js:60281:17)
    at Function.connect (http://localhost:51944/dart_sdk.js:58470:27)
    at Function.connect (http://localhost:51944/dart_sdk.js:58362:33)
    at connection.Connection.new.connect (http://localhost:51944/packages/mailer/src/smtp/connection.dart.lib.js:176:50)
    at connect.next (<anonymous>)
    at runBody (http://localhost:51944/dart_sdk.js:40590:34)
    at Object._async [as async] (http://localhost:51944/dart_sdk.js:40621:7)
    at connection.Connection.new.connect (http://localhost:51944/packages/mailer/src/smtp/connection.dart.lib.js:172:20)
    at connect (http://localhost:51944/packages/mailer/src/smtp/smtp_client.dart.lib.js:108:17)
    at connect.next (<anonymous>)
    at runBody (http://localhost:51944/dart_sdk.js:40590:34)
    at Object._async [as async] (http://localhost:51944/dart_sdk.js:40621:7)
    at Object.connect (http://localhost:51944/packages/mailer/src/smtp/smtp_client.dart.lib.js:105:18)
    at send (http://localhost:51944/packages/mailer/src/smtp/mail_sender.dart.lib.js:164:43)
    at send.next (<anonymous>)
    at runBody (http://localhost:51944/dart_sdk.js:40590:34)
    at Object._async [as async] (http://localhost:51944/dart_sdk.js:40621:7)
    at Object.send (http://localhost:51944/packages/mailer/src/smtp/mail_sender.dart.lib.js:162:18)
    at sendEmail (http://localhost:51944/packages/pronto/pages/product_page/product_detail_screen.dart.lib.js:46073:27)
    at sendEmail.next (<anonymous>)
    at runBody (http://localhost:51944/dart_sdk.js:40590:34)
    at Object._async [as async] (http://localhost:51944/dart_sdk.js:40621:7)
    at dashboard_screen$._EmailSender.new.sendEmail (http://localhost:51944/packages/pronto/pages/product_page/product_detail_screen.dart.lib.js:46059:20)
    at dashboard_screen$._EmailSender.new.<anonymous> (http://localhost:51944/packages/pronto/pages/product_page/product_detail_screen.dart.lib.js:46055:36)
    at Generator.next (<anonymous>)
    at runBody (http://localhost:51944/dart_sdk.js:40590:34)
    at Object._async [as async] (http://localhost:51944/dart_sdk.js:40621:7)
    at http://localhost:51944/packages/pronto/pages/product_page/product_detail_screen.dart.lib.js:46054:575
    at ink_well._InkResponseState.new.[_handleTap] (http://localhost:51944/packages/flutter/src/material/icon_button.dart.lib.js:40468:31)
    at tap.TapGestureRecognizer.new.invokeCallback (http://localhost:51944/packages/flutter/src/gestures/recognizer.dart.lib.js:190:18)
    at tap.TapGestureRecognizer.new.handleTapUp (http://localhost:51944/packages/flutter/src/gestures/tap.dart.lib.js:409:40)
    at tap.TapGestureRecognizer.new.[_checkUp] (http://localhost:51944/packages/flutter/src/gestures/tap.dart.lib.js:217:12)
    at tap.TapGestureRecognizer.new.handlePrimaryPointer (http://localhost:51944/packages/flutter/src/gestures/tap.dart.lib.js:166:23)
    at tap.TapGestureRecognizer.new.handleEvent (http://localhost:51944/packages/flutter/src/gestures/recognizer.dart.lib.js:426:16)
    at pointer_router.PointerRouter.new.[_dispatch] (http://localhost:51944/packages/flutter/src/gestures/pointer_router.dart.lib.js:86:9)
    at http://localhost:51944/packages/flutter/src/gestures/pointer_router.dart.lib.js:112:26
    at LinkedMap.new.forEach (http://localhost:51944/dart_sdk.js:27679:11)
    at pointer_router.PointerRouter.new.[_dispatchEventToRoutes] (http://localhost:51944/packages/flutter/src/gestures/pointer_router.dart.lib.js:110:29)
    at pointer_router.PointerRouter.new.route (http://localhost:51944/packages/flutter/src/gestures/pointer_router.dart.lib.js:105:37)
    at binding$5.WidgetsFlutterBinding.new.handleEvent (http://localhost:51944/packages/flutter/src/gestures/binding.dart.lib.js:364:26)
    at binding$5.WidgetsFlutterBinding.new.dispatchEvent (http://localhost:51944/packages/flutter/src/gestures/binding.dart.lib.js:352:24)
    at binding$5.WidgetsFlutterBinding.new.dispatchEvent (http://localhost:51944/packages/flutter/src/rendering/layer.dart.lib.js:5427:13)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerEventImmediately] (http://localhost:51944/packages/flutter/src/gestures/binding.dart.lib.js:328:14)
    at binding$5.WidgetsFlutterBinding.new.handlePointerEvent (http://localhost:51944/packages/flutter/src/gestures/binding.dart.lib.js:302:43)
    at binding$5.WidgetsFlutterBinding.new.[_flushPointerEventQueue] (http://localhost:51944/packages/flutter/src/gestures/binding.dart.lib.js:292:14)
    at binding$5.WidgetsFlutterBinding.new.[_handlePointerDataPacket] (http://localhost:51944/packages/flutter/src/gestures/binding.dart.lib.js:283:54)
    at Object.invoke1 (http://localhost:51944/dart_sdk.js:190401:7)
    at _engine.EnginePlatformDispatcher.__.invokeOnPointerDataPacket (http://localhost:51944/dart_sdk.js:171080:15)
    at _engine.PointerBinding.__.[_onPointerData] (http://localhost:51944/dart_sdk.js:171962:49)
    at http://localhost:51944/dart_sdk.js:172400:28
    at http://localhost:51944/dart_sdk.js:172356:16
    at loggedHandler (http://localhost:51944/dart_sdk.js:172061:11)

@close2
Copy link
Collaborator

close2 commented May 6, 2022

This library doesn't work in flutter web.
A browser simply doesn't allow you to open raw sockets. You can only open http connections from inside a browser.

@close2 close2 closed this as completed May 6, 2022
@nuno84
Copy link

nuno84 commented Jun 9, 2023

Hi, this also applies to an edge-function env, correct? I am experiencing the same error.
Any alternative for it?
Thanks

@close2
Copy link
Collaborator

close2 commented Jun 12, 2023

@nuno84 Not allowing smtp connections in edge environments is not because of technical reasons.
Your provider might not allow them to prevent spam,...

If the usual ports are blocked you might try to find a provider which exposes its smtp service on an unusal port.

Another workaround (which would also be a good solution for flutter web based applications) is to use for instance supabase: trigger a transactional mail whenever you write into a specific database (unless supabase doesn't allow this in their terms and conditions...)

If you find another mail service which allows sending mails through an http API please add it to this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants