Git Product home page Git Product logo

react-mailto's Introduction

React <Mailto> Build Status

A react component to create and display a mailto link.

Getting Started

  • Install with NPM - npm install --save react-mailto

Usage

var React  = require('react');
var Mailto = require('react-mailto');

var Component = React.createClass({
  render: function () {
    return (
      <Mailto email="[email protected]" obfuscate={true}>
        Email me!
      </Mailto>
    );
  }
});

Options

Property Type Argument Default Description
email string <required> null email address of the intended recipient.
obfuscate boolean <optional> false show the email address in the status bar.
headers object <optional> null any standard mail header fields. The most commonly-used of these are "subject", "cc", and "body" (which is not a true header field, but allows you to specify a short content message for the new email).

Developing

react-mailto is built using ES6. Run the following task to compile the src/ into dist/.

npm run build

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

License

Copyright (c) 2015 Jason Bellamy Licensed under the MIT license.

react-mailto's People

Contributors

handtrix avatar jasonbellamy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

react-mailto's Issues

Error on React 16

Error on React 16 while running for production mode .
The Error is
Desktop/****/node_modules/react-mailto/dist/react-mailto.js:106
children: _react.PropTypes.node.isRequired,
^

TypeError: Cannot read property 'node' of undefined

Add E-Mail Headers

I would be really nice to allow setting email headers such as cc, body, subject etc.

In addition to the email address, you can provide other information. In fact, any standard mail header fields can be added to the mailto URL you provide. The most commonly-used of these are "subject", "cc", and "body" (which is not a true header field, but allows you to specify a short content message for the new email). Each field and its value is specified as a query term.

https://developer.mozilla.org/de/docs/Web/Guide/HTML/Email_links
https://tools.ietf.org/html/rfc2368

Example

mailto:[email protected]?Subject=react-mailto%20needs%20header&cc=cc%40example.com&bcc=bcc%40example.com&body=This%20is%20just%20an%20example.%20%0AThere%20a%20lot%20more%20headers%20that%20could%20be%20added.

Try Me!

Integration

I suggest to add an headers property.

<Mailto 
  email="[email protected]" 
  headers={{
    bcc: '[email protected]',
    cc: '[email protected]',
    subject: 'someSubject',
    body: 'some body',
    ...
  }}>
  Email me!
</Mailto>

Header

Is it a possible to add attachment in mail?

Email need not be required

Having all recipient's in bcc seems like a fairly common use-case for notices, in which case there need not be anything in the to field.

Warning when on React 15

I'm on React 15.5.4 and I'm getting the following error when using react-mailto:

Warning: Accessing PropTypes via the main React package is deprecated. Use the prop-types package from npm instead.

React 16 solution

Plz remove imports and change with:

import React, { Component } from 'react';
import PropTypes from 'prop-types';

Cannot read property 'node' of undefined

In the react v-16>

103 | }(_react.Component);
104 |
105 | Mailto.propTypes = {

106 | children: _react.PropTypes.node.isRequired,
107 | email: _react.PropTypes.string.isRequired,
108 | headers: _react.PropTypes.object,
109 | obfuscate: _react.PropTypes.bool

shows the error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.