Can I use HTML5 to send a client-side email?

前端 未结 6 1252
没有蜡笔的小新
没有蜡笔的小新 2020-12-01 19:35

I want to send an email in HTML5. I don\'t want to force the user to open a mail client, I want to send the email directly from the web page.

On a side note, is ther

6条回答
  •  暖寄归人
    2020-12-01 20:22

    Send email directly from Javascript

    From official resource:

    How does it work?

    1. Connect your email service Choose from a wide variety of email services. We support both transactional email services (Mailgun, Mailjet, Mandrill, SendGrid, Amazon SES and Postmark) and personal email services (AOL, Gmail, FastMail, iCloud, Mail.ru, Outlook, Yahoo, Yandex and Zoho).

    2. Create email templates Choose from a list of our template designs, or easily build your own. Templates are parametrized, so that you can further customize them via Javascript.

    3. Send email with our Javascript API Add our Javscript SDK, and start sending emails!

    Here's what a typical call looks like:

    var service_id = 'my_mandrill';
    var template_id = 'feedback';
    var template_params = {
      name: 'John',
      reply_email: 'john@doe.com',
      message: 'This is awesome!'
    };
    
    emailjs.send(service_id,template_id,template_params);
    

    All existing APIs require using a secret key, which you obviously wouldn't want to share in your front-end code. Specified service overcome this by allowing sending only predefined templates, so for a "Share with a friend" feature you'd create a template called "share".

提交回复
热议问题