Sending Email From Flutter App Using flutter_email_sender or mailer - flutter

I am trying to Send mail from Flutter App using flutter_email_sender
sendEmail(){
final Email email = Email(
subject: "Text",
body: "${User.userEmail + User.userCategory}",
recipients: ["${User.userEmail}"],
isHTML: false,
);
FlutterEmailSender.send(email);
}
But the above code is opening mail application which is not I am trying to do.
I'm trying to send the mail on button click directly without using this application.
I know there is package called mailer, can any one suggest how to implement this with my backend (php).

Related

Flutter - How to reply to an email through enough_mail

I am using enough_mail dependency for my mail client Flutter app. My requirement is how to reply to a mail. Here is how I build the Message.
You need to initialize MessageBuilder bellow way
MessageBuilder messageBuilder = MessageBuilder.prepareReplyToMessage(
mimeMessage,
MailAddress('', senderEmail),
replyAll: false,
quoteOriginalText: true,
replyToSimplifyReferences: true
)

Cannot send password request reminder using Flutter connected with Parse-server

Hello i have app written in flutter which uses data from parse server.
According to flutter doc:
/// Reset password
response = await user.requestPasswordReset();
if (response.success) {
user = response.result;
}
I'd like to send e-mail using my parser with change password link.
When i press button with that function assigned - i get information: "E-mail sent"
On flutter side i'm getting that output:
Function: ParseApiRQ.requestPasswordReset
I/flutter (28247): Status Code: 200
I/flutter (28247): Payload: {"className":"_User","email":"testazaz#gmail.com"}
On parser side i have installed something like this:
simple-parse-smtp-adapter Configured as doc says.
I don't getting any Error/Info logs from parser. Can you tell me how to configure it properly? Maybe you know other way - how to connect flutter with parser to send e-mail verification or password change e-mails.
After couple days i finally resolved this problem with help of #DaviMacêdo.
I implemented Sendgrid Adapter.
In your parse node-modules folder install this module using cmd:
npm i parse-server-sendgrid-adapter
Remember to require module at the top of the file:
var SimpleSendGridAdapter = require('parse-server-sendgrid-adapter');
var api = new ParseServer({
...,
emailAdapter: SimpleSendGridAdapter({
apiKey: 'sendgridApiKey',
fromAddress: 'fromEmailAddress',
})
});
You can get api key here
and set up sender e-mail here
I hope it helps saving much time for others facing the same problem!

Teams not displaying email sent via SendGrid

I'm trying to post to a Teams channel via the email address using SendGrid. However, the emails I send via SendGrid are not appearing. I ended up adding my personal email address as well, and I do receive that one as well as seeing the Teams email address in the To: field. I can also see in SendGrid dashboard that the email was send and delivered to the Teams channel address. I have validated that this address is correct, and have also posted via my non-work email address to that channel, so I know it's not because of a typo or an external email address. My guess is that there is something in the email meta data that is making Teams reject the email? Anyone have ideas 1) why Teams won't post the email coming from SendGrid and 2) how I might modify my request in SendGrid so that it works? Also, alternative suggestions on sending emails (for free) from nodejs are welcome.
Here is the code I'm using to send the email for reference:
var msg = {
to: ['TEAMSCHANNELID#amer.teams.ms','mycompanyemail#company.com'], // ChatBot Support Team, General Channel
from: 'noreply#chatbotapimonitor.com',
subject: `Service Interruption Notice: API ${test} is down (via ${functionName})`,
text: `API ${test} failed with error ${error}`,
html: `API ${test} failed with error ${error}`
};
try {
await sgMail.send(msg);
} catch (err) {
context.log(err);
}
It turns out that Teams won't accept incoming emails if the From address domain does not match the actual "sent from" domain. I recognized this by the "Sent via sendgrid.net" message I saw in Outlook when the emails were sent to me as well.
I was able to get the out of the box Incoming Webhooks enabled, and using that instead of SendGrid emails got around the problem. I got the URL from the webhook configuration and then was able to call it like so:
var headers = { 'ContentType': 'application/json'}
var body = {
'#context': 'https://schema.org/extensions',
'#type': 'MessageCard',
'themeColor': 'FF0000',
'title':`API ${test} is down: Service Interruption Notice`,
'text': `API ${test} failed with error ${error}.\n\r\n\rReported by ${functionName} during test started on ${now.toString()}`
};
var res = await request({
url: url,
method: 'POST',
headers: headers,
json: body,
rejectUnauthorized: false
});
The themeColor doesn't appear in all channels, but I have it working as a nice red/green indicator on Teams desktop.
Perhaps your organization limits the sending ability to only certain domains? Someone with admin rights can check it under Teams settings => Email integration
yeah that's what I meant - making your own Connector app and side-loading. If you go ahead with it, please let me know - would love to know how it works out
Yes exactly making your own Connector would work.

Send a contact us form details to email in Dart

I am making a Contact us form page in my Flutter app and would like to send the details of the form (email of the user, name and the message) to my email address when the user hits the Send button. I don't want to launch the gmail app from phone for this. Are there any other ways to this?
Thanks!
Of course, you can.
You can use the flutter_email_sender package or flutter_mailer package. Both of them are very similiar.
For example if you are using flutter_email_sender package,
final Email myFormEmail = Email(
body: 'Email body', // This could be from the form field's value
subject: 'Email subject', // Subject (maybe type of question, etc)
recipients: ['example#example.com'], // This is receiver (maybe your email)
cc: ['cc#example.com'],
bcc: ['bcc#example.com'],
attachmentPaths: ['/path/to/attachment.zip'], // Attachments
isHTML: false,
);
And then inside the 'SEND' button, add this kind of code:
await FlutterEmailSender.send(myFormEmail);
Please check "mailer" package from flutter. It will use smtp to send email from background without opening userinterface app. It has gmail, yahoo mail, mailgun options to send email.
The Reference link :
https://pub.dartlang.org/packages/mailer

Is it posible in flutter to create a button that opens the email app with the email account "TO" already writen?

I wante to create a buton to be used when the suer wants to report a problem they can press it an will send them to their email app with my email already writen on it so they only need to write the email and I was wondering if that is a posibility on flutter.
Yes. Take a look at the url_launcher package. You can even set the subject and the body of the email.
Just search through the flutter packages. I personally have used flutter_email_sender which has a pretty full feature set, including subject, body and also attachments.
e.g.
final Email email = Email(
body: 'Email body',
subject: 'Email subject',
recipients: ['example#example.com'],
attachmentPaths: ['/path/to/attachment.zip'],
);
await FlutterEmailSender.send(email);