Navigation

    Quasar Framework

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Send Email from Quasar App Example Needed

    Help
    4
    15
    59
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cynderkromi last edited by

      I need my Quasar app to gather info from my IndexedDB (via Dexie) and send the information in an email.

      I have no idea how to even start this. I don’t even know just how to get Quasar to send an email, or JavaScript, because I’m brand new to it all.

      Would anyone have the time to post an example that I can copy and learn from? Thanks!

      1 Reply Last reply Reply Quote 0
      • S
        sebag last edited by

        don’t think you can send an e-mail directly from the frontend, you need some backend API (Node JS, PHP) and SMTP server, that will send an e-mail for you

        C 1 Reply Last reply Reply Quote 0
        • P
          pazarbasifatih last edited by pazarbasifatih

          The thing you want to setup for you app on your own is a multi million dollar business 😃 You have to be very dedicated with it.
          If nothing else works, give up the IndexedDB for good and try Firebase Extensions for that.
          You can either Trigger an email upon an event in the Firestore database and make use of an email template by populating the HTML markup with the data from your Firestore.
          Or directly share login email and displayName data with Mailchimp and manage everything visually by creating marketing campaigns etc from there, but it’s a payed service. 💰

          The question is… how much time do you want to spend on all of that?

          1 Reply Last reply Reply Quote 0
          • C
            cynderkromi @sebag last edited by

            @sebag I sometimes want to send emails via SMTP, as my users will be sending about 50 emails at a time sometimes. But I also want the option to fire the local email client and have them send emails that way too. Thanks for the info.

            @pazarbasifatih I have to use indexedDB, it’s going to be a desktop app. And I am spending a lot of time on because I enjoy it.

            1 Reply Last reply Reply Quote 0
            • beets
              beets last edited by

              If this is a user facing app, you definitely need some sort of backend to decide that it’s okay to send an email.

              If this is an admin only app, and is protected behind at least basic auth, you probably could send emails direct via amazon SES, mailgun, or other similar API services. But be aware that you’d be putting sensitive credentials in javascript with is just asking for abuse unless only trusted users are allowed to download that javascript.

              C 1 Reply Last reply Reply Quote 0
              • P
                pazarbasifatih last edited by pazarbasifatih

                @cynderkromi
                Oh ok, I didn’t realize you wanted an email client. I thought it was for mailing campaigns.
                You can use Nodemailer with a Nodejs backend. (You’ll need cors to unblock the requests coming from the browser. I don’t know the nature of your app, try it with or without.)

                const nodemailer = require('nodemailer');
                const cors = require('cors')({origin: true});
                

                Then you’ll need some sort of smtp configuration for the source mail. you can retrieve them and save them in the env maybe… I don’t know… eg:

                let transporter = nodemailer.createTransport({
                    service: 'gmail',
                    auth: {
                        user: process.env.EMAIL_USERNAME,
                        pass: process.env.EMAIL_PASSWORD
                //     user: 'yourgmailaccount@gmail.com',
                //     pass: 'yourgmailaccpassword'
                    }
                });
                

                Then you’ll be sending the mail. You’ll define the receiver via a request to this Nodejs module. The request will include the destination. You can ask for these informations in a Quasar input element and vmodel it to a data, then send the request when user hits the send Quasar button. Take a look at this stackover link later on if you’re looking for different confs.

                let sendMail =((req, res) => {
                    cors(req, res, () => { //cors may or may not be necessary
                const dest = req.query.dest;
                
                        const mailOptions = {
                            from: process.env.EMAIL_USERNAME, // Something like: Jane Doe <janedoe@gmail.com>
                            to: dest,
                            subject: 'Spam mail my client sends', // email subject
                            html: `<p style="font-size: 16px;">Buy this now!!</p>
                                <br />
                                <img src="....png" />
                            ` 
                // email content in HTML
                        };
                })})//check the paranthesis please
                
                
                module.exports = sendMail;
                C 1 Reply Last reply Reply Quote 0
                • C
                  cynderkromi @beets last edited by

                  @beets It’s user-facing, but there are limited users. It’s a dog trial secretarial software where the secretaries take dog trial entries (people, dogs, runs) and send emails to the people who have entered with their entry information. I currently have a working one in FileMaker but I don’t like it much, so am rewriting it in Quasar. (liking Quasar a LOT better so far). Thanks for your information!

                  @pazarbasifatih oh yeah nope for a mailing campaign I’d definitely use Mail Chimp. I have read about NodeMailer and that looks good, thanks so much for your example! I will work on that.

                  This is a huge learning curve for me so my development speed is super slow, but it’s fun.

                  Long answer longer… I’m excited that I have a very basic working application now, even uploaded it to my host: Demo App. The only things that work now are the People and Dogs buttons to add people and dogs. I wanted to make sure it will publish okay before going on. And it’s cool that with Quasar I can write it for all types of distribution, though it will be a Desktop App in the end.

                  I will have a super limited market for this and I definitely won’t be getting fully compensated for my time. Most of the software that exists like this is written in MSAccess and runs in Windows only. I’m a retired programmer and a dog trial secretary and I use a Mac, so I figured I would write a nice one myself. 🙂

                  1 Reply Last reply Reply Quote 1
                  • C
                    cynderkromi @pazarbasifatih last edited by

                    @pazarbasifatih So I am able to use your example and set up nodemailer to send email through my Quasar project when I run my project via electron on my MacBook. However, when I run the application without electron, and develop in the browser, I get an error when using the same code:

                    Error: Cannot find module 'net'
                        at webpackEmptyContext (eval at ./node_modules/defaultable sync recursive (2.js:22), <anonymous>:2:10)
                        at Object.workaround_require (defaultable.js?b308:49)
                        at require (defaultable.js?b308:77)
                        at eval (server.js?c5b7:9)
                        at defaulter (defaultable.js?b308:83)
                        at defaultable (defaultable.js?b308:63)
                        at good (defaultable.js?b308:174)
                        at Object.eval (server.js?c5b7:5)
                        at eval (server.js:242)
                        at Object../node_modules/hbo-dnsd/server.js (vendor.js:3081)
                    

                    What do I need to do differently to run it through the browser? I am also working on a small Quasar app that will allow people to join a club via an online form. My big app will be run on the desktop, but now I want this little app to run on the web. Thanks!

                    beets 1 Reply Last reply Reply Quote 0
                    • beets
                      beets @cynderkromi last edited by

                      @cynderkromi Note that pazarbasifatih’s example used nodemailer, which is meant for node. The net module is also a node module, which won’t work on the browser.

                      Again, I’d rethink this since it’s a user facing app. Trying to skip a simple nodejs backend to send emails means you’re bundling private credentials to the whole internet. On the nodejs backend, you can keep using nodemailer, and just make a simple POST endpoint that will send an email for you.

                      1 Reply Last reply Reply Quote 0
                      • C
                        cynderkromi last edited by

                        Hmm okay. PHP does this fairly easily, so I’m not sure why I can’t do it from Quasar. There has got to be a way to send the occasional email from an online Quasar app. I will keep hunting.

                        beets 1 Reply Last reply Reply Quote 0
                        • beets
                          beets @cynderkromi last edited by

                          @cynderkromi said in Send Email from Quasar App Example Needed:

                          There has got to be a way to send the occasional email from an online Quasar app. I will keep hunting.

                          Well there is, if you use a service like AWS, sendgrid, mailgun, etc. Then you’d use axios to post to their API to send a mail. But I must re-iterate again, by doing so, your secret credentials are public, and anyone could grab them, use them for spam or phishing (since it will show up as sent by you) and rack up a bill in your name. I’d highly suggest to make just a simple PHP / nodejs backend that accepts a few parameters, and sends out the email.

                          1 Reply Last reply Reply Quote 0
                          • C
                            cynderkromi last edited by

                            Okay, I am using https://www.emailjs.com/ and it’s working great so far. I need to now also add a PayPal button to it so I can combine the email and the Payment!

                            beets 1 Reply Last reply Reply Quote 0
                            • beets
                              beets @cynderkromi last edited by

                              @cynderkromi +1, they are basically just a paid backend. Will work fine if you are in one of the cheaper tiers. If more than that I’d recommend rolling your own PHP script.

                              They also explain what I was trying to say in their FAQ:

                              Can’t I use services like Sendgrid or Mandrill directly?

                              All email services require some sort of authentication to send the emails on your behalf. That makes it a really bad idea to use them directly from client side – revealing your password or your secret keys will allow anyone send emails on your behalf.

                              EmailJS keeps your authentication details on the server side, and the client side code just triggers a predefined email template, similarly to how any client-server application is working.

                              1 Reply Last reply Reply Quote 0
                              • C
                                cynderkromi last edited by cynderkromi

                                They allow for 200 emails a month. If we get 200 a year we’ll be doing well! 😃

                                1 Reply Last reply Reply Quote 0
                                • C
                                  cynderkromi last edited by

                                  It’s done!! I’m so excited. LOL. The little application now will take payment via PayPal AND send me an email, and the person joining an email. Since we don’t usually get more than 40 members per year, this will work great. 🙂

                                  http://bristlenosedog.com/join/#/

                                  1 Reply Last reply Reply Quote 0
                                  • First post
                                    Last post