Flutter (mailer package): mailing from within the app. not receiving mail - email

I am working on an app in flutter, and I would like to have a "give feedback option". this form consists of 1 text field where the message is typed, and 1 button to submit and sent the feedback.
I am currently using the mailer(1) dart package to do this for me, but so far I have not been able to send and receive a mail in my inbox.
I have used flutter_mailer and mailer, both without any success. I followed instructions and tried to do the same as the example, but I can not get it working.
the show code is the method to handle the email.
void sendEmail(String message) async {
_isLoading = true;
notifyListeners();
print(message);
String username = 'matthijs******#gmail.com';
String password = '******';
final SmtpServer server = gmail(username, password);
final feedbackMessage = new Message()
..from = new Address(username, _authUser.email)
..recipients.add('m.dethmers2#hotmail.nl')
..ccRecipients.addAll([_authUser.email])
..subject = 'Feedback from ${_authUser.id} ${new DateTime.now()}'
..text = message
..html = "<h1>Test</h1>\n<p>message</p>";
final sendReports = await send(feedbackMessage, server, timeout:
Duration(seconds: 15));
_isLoading = false;
notifyListeners();
print('email send');
}
i would like to see an email appear in my inbox with the written message of the user in there.

so, it seems like you should create an app password of the desired account.
you can ollow this link https://support.google.com/accounts/answer/185833?hl=en to create an app password. use this password in conjunction with the email in the mailer implementation and everything should work!

Related

Calendar clientViaUserConsent it gives me Authorization Error while creating event

clientViaUserConsent opens URL in browser but it said invalid request. this URL is generated internally from lib. I had double-checked my ClientId for both platforms but still face issues for getting AuthClient for create a calendar event.
I used the below packages to create events in the google calender.
googleapis: ^8.1.0
googleapis_auth: ^1.3.0
static final androidClientId = ClientId('xxxxxxxx.apps.googleusercontent.com');
static final iOSClientId = ClientId('xxxxxxx.apps.googleusercontent.com');
final _clientID = Platform.isAndroid ? EventProvider.androidClientId : EventProvider.iOSClientId;
final _scopes = [CalendarApi.calendarScope];
clientViaUserConsent(_clientID, _scopes, prompt).then((AuthClient client) {
var calendar = CalendarApi(client);
}
void prompt(String url) async {
print(" => $url");
if (await canLaunch(url)) {
await launch(URL);
} else {
throw 'Could not launch $url';
}
}
I am referring to this article for creating an event in google calendar.
https://blog.codemagic.io/google-meet-events-in-flutter/
https://medium.com/flutter-community/flutter-use-google-calendar-api-adding-the-events-to-calendar-3d8fcb008493
You are seeing that error because the app hasn't been verified. If you are the app developer I advise you to check the App Verification FAQ to learn more about the verification steps. If you aren't the developer, you could try to enable the less secure app access but please be mindful of the consequences:
Less secure apps can make it easier for hackers to get in to your account, so blocking sign-ins from these apps helps keep your account safe.

How to send message to multiple number in WhatsApp in one time?

I'm trying to send a message to multiple phone numbers via WhatsApp using Flutter:
sendMessage() async {
var number = ["201020402642", "201030666895"];
var baseUrl = "https://api.whatsapp.com/send/";
var urlIos = "";
number.forEach((element) async {
var url = baseUrl +"?phone=${element} &text=msg";
if (await canLaunch(url)) {
await launch(url);
} else {
print("not installed");
}
});
}
It only sends a message to the last number.
Is there a way to send a message to a group of numbers?
Unfortunately, there's no way to send a message for more than 1 number at the same time using deep links. The only way you can do something like this is by using the WhatsApp business API through REST requests. There are some third-party software with this feature like https://www.twilio.com/whatsapp
Here is the WhatsApp API doc
https://developers.facebook.com/docs/whatsapp/api/messages/#sending-messages

How to only open email app and attach a file?

I'm trying to only OPEN an email app i.e. Outlook, Gmail, etc. and with an attachment already attached. Ready for the user to write a subject and send it to someone. Again I'm not looking to send it automatically, only open the app with the attachment attached.
So far the only thing I found is this: https://pub.dev/packages/launchers
But I am getting an error message: "No implementation found for method send on channel GitHub.com/sunnyapp/launchers_compose"
Here is my code: I am at a loss. I feel like this should be an easy thing to do. P.S most email openers can open an email app but can't attach attachments. I also know this is for mobile only. Android and iOS.
final Email email = Email(
body: "This Email was Created by TRS to send an Excel File!",
subject: "$excelName",
recipients: [""],
attachmentPath: fullPath,
);
Iterable<String> platformResponse;
try {
final results =
await LaunchService().launch(composeEmailOperation, email);
print(results);
platformResponse = results.allAttempts.entries.map((entry) {
print("Provider = ${entry.key}\nResult = ${entry.value}");
return "P";
});
} catch (error, stack) {
print(error);
print(stack);
platformResponse = ["Error: $error"];
}
You can use https://pub.dev/packages/share_plus package:
String filename = './docs/myfile.xlsx'
Share.shareFiles([filename], text: 'This Email was Created by TRS to send an Excel File!');
This opens gmail or whatever app you have with attachment and text but this particular code only works on mobile, not on desktop. I

Have Blazor InputText keep focus after submitting

I'm building a little chat widget to my Blazor app. It works too, but to make it work more fluently, I'd like to make the focus stay in the InputText after submitting a message.
Any time I press enter, the message gets sent and received correctly. Unfortunately, the focus also goes wherever. This doesn't let you quickly type multiple messages into the chat.
I guess I could make a JS interop method sending the focus back to the InputText and call that after every submit, but I'd prefer to find a js-free solution.
My Razor markup is this:
<EditForm Model="message" OnSubmit="SendMessage">
<InputText type="text" #bind-Value="message.Message" />
</EditForm>
I send the message like this:
private async Task SendMessage()
{
Console.WriteLine("Send message " + message.Message);
var t = Service.SendMessage(message);
messages.Add(message);
message = new Library.Models.ChatMessage();
await t;
Console.WriteLine("Sending finished.");
}
This does not normally happen in an HTML form. The loss of focus is caused by the re-rendering of the tree.
As a workaround, not real pretty:
private async Task SendMessage()
{
Console.WriteLine("Send message " + message.Message);
var copy = new Library.Models.ChatMessage { Message = message.Message };
var t = Service.SendMessage(copy);
messages.Add(copy);
// message = new Library.Models.ChatMessage(); -- this was the problem
message.Message = "";
await t;
Console.WriteLine("Sending finished.");
}
I experimented a little with #key but I couldn't get that to work.

Send email from Contact form directly without opening gmail application

I want to send email directly to admin email without opening gmail application through URL package in flutter URL package work perfectly but that is not required. I want to do it through fire-base where I also want to save all data send to admin email. I need to know the email function of firebase or any such function that help me to send direct email.
_launchURL(String toMailId, String subject, String body) async {
var url = 'mailto:$toMailId?subject=$subject&body=$body';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
}