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
Related
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).
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);
I send 200 emails to a community of students via a google-spreadsheet attached google script.
My mailing call is as follow :
MailApp.sendEmail(
"toto#gmail.com", // targetEmail
"HELLO FROM KING OF NIGERIA", // emailTitle
"", // something
// emailContentHTML
{ htmlBody: "<b>Hello John</b><br><p>I'am king of Nigeria.<br>Got gold everywhere.<br>Need your help I'am in danger.<br>Want to share with you.<br>Could you send me 50$<br>Sinceraly, your friend.</p>"}
);
The script being run by my google account john.Doe#entreprise.com, the 200+ participants see the email as coming from me (john.Doe#entreprise.com). I understand this is fair game to limit spamming and co, but my company has a gmail entreprise.com domain name and I would like a solution so to not get dozens of "Thanks you" alerts in the following days. For sure, I do NOT want them to keep me in their following discussion.
So I look for something such as create a no-reply#entreprise.com account, and then a js thing so the script sign email with this no-reply#entreprise.com email.
Also, is there a way to programatically sign the google-script mailing from an other account of my company (no-reply#entreprise.com) ?
Note : google-script-manual
Since the script is being run under your Gmail account, the easiest way to do this is to add noReply: true to the message object. This will result in the email being sent from a generic noreply#enterprise.com email. The noreply email account does not need to be created for this to work.
Note that this does not work for personal Gmail accounts.
The documentation for this is at this link as noted in Edward Wall's answer.
MailApp.sendEmail(
"toto#gmail.com", // targetEmail
"HELLO FROM KING OF NIGERIA", // emailTitle
"", // something
// emailContentHTML
{ htmlBody: "<b>Hello John</b><br><p>I'am king of Nigeria.<br>Got gold everywhere.<br>Need your help I'am in danger.<br>Want to share with you.<br>Could you send me 50$<br>Sinceraly, your friend.</p>",
//send from generic noReply#enterprise.com address
noReply: true}
);
You could use the following method from the MailApp documentation
sendEmail (title, replyTo, subject, body)
Setting the replyTo to your do-not-reply email will mean that anyone who presses reply will send their email to your do-not-reply mailbox
MailApp.sendEmail (
"email#example.com", // targetEmail
"do-not-reply#example.com", // reply to email
...
)
Link to MailApp Documentation
The easiest way to send email from the no-reply#enterprise.com account is having the Apps Script will have to run under the authority of that account.
How you achieve this depends on how the script is being executed. If it is being executed by a Trigger, the Trigger must be created by the no-reply account.
If the script is published as a web-app, it should be deployed from the no-reply account, and set to execute as no-reply#enterprise.com.
If the script is triggered manually, it will have to be triggered by somebody logged in as the no-reply user.
A simpler option is to set a reply-to address, as shown in Edward Wall's answer.
I want to create an 'Email to friend' form where the user enters an email address, and an email is sent to that address with a link to the current page url.
How do I set the receiver to be the email entered into the form?
plugin.tx_powermail.settings.setup.receiver.overwrite.email = TEXT
plugin.tx_powermail.settings.setup.receiver.overwrite.email.data = myemailfield??
.data = GP:tx_powermail_pi1|field|markername
But beware that your system can send emails to any email address that a user wants. Someone could use it for spaming with a "tipafriend" function.
Laravel5 Currently i am facing issue unable to check the status email is sent and not even getting email failed and i am using mandrill api for sending emails
$mail = Mail::send('emails.pendingorder', $data , function($message) use ($domain, $order)
{
if ($order->other_email) {
$message->from($domain->email, $domain->website);
$message->to($order->email, $order->name)->subject('test Email ');
$message->bcc($order->other_email, $order->name)->subject('test Email ');
}else{
$message->from($domain->email, $domain->website);
$message->to($order->email, $order->name)->subject('test Email ');
}
});
if($mail){
echo 'sent';
}else{
echo 'Fail';
}
The second thing..
i created email templates in blade and i want to preview email in ckeditor if there any any chaning or modification require then i edit the content and send email. i havn't any idea how to to this :(
Its my first try with laravel email and i am totally stuck with it
Do you have correct configuration in config/mail.php? Remember to change pretend to false. Also, Mail::send returns void, so you will have to check status on your mandrill account.
For editing email before sending it:
create form with ckeditor
fill this form with your default template
after submitting you have email body in your request, you can pass it to your email view
If you want your email to be fully editable, instead of having email view with only one variable you can use:
Mail::raw('This will be body of your email', function($message) {
// ...
});