I am using dependency https://pub.dev/packages/mailer to send auto message through flutter web application for this part I am using the following code.
String username="************";
String password = "*******";
var smtpServer = gmail(username,password);
final message = Message()
..from = Address(username, 'Truck App')
..recipients.add('******')
..subject = 'Testing'
..text = msg.text
..html = "<h1>Test</h1>\n<p> Hey! Here\'s some text</p>";
try{
final sendReport = await send(message, smtpServer);
print('Message sent:'+sendReport.toString());
} on MailerException catch (e){
print('Message not sent.');
for(var p in e.problems){
print('Problem: ${p.code}: ${p.msg}');
}
}
final equivalentMessage = Message()
..from = Address(username, 'Your name ')
..recipients.add(Address('******'))
..ccRecipients.addAll([Address('******')])
..bccRecipients.add('*********')
..subject = 'Test Dart Mailer library :: ::'
..text = 'This is the plain text.\nThis is line 2 of the text part.'
..html = '<h1>Test</h1>\n<p>Hey! Here is some HTML content</p>';
final sendReport2 = await send(equivalentMessage, smtpServer);
var connection = PersistentConnection(smtpServer);
await connection.send(message);
await connection.send(equivalentMessage);
await connection.close();
but I am getting the error like this:
js_helper.dart:1130 Uncaught Unsupported operation: Socket constructor
at Object.b (http://localhost:52881/main.dart.js:4220:3)
at Object.aVb (http://localhost:52881/main.dart.js:8007:31)
at Object.aVc (http://localhost:52881/main.dart.js:8034:5)
at http://localhost:52881/main.dart.js:79815:14
at awO.a (http://localhost:52881/main.dart.js:5925:71)
at awO.$2 (http://localhost:52881/main.dart.js:38402:23)
at Object.W (http://localhost:52881/main.dart.js:5911:19)
at Ku.yv (http://localhost:52881/main.dart.js:79822:10)
at http://localhost:52881/main.dart.js:25197:14
at awO.a (http://localhost:52881/main.dart.js:5925:71)