본문 바로가기
front-end/React Native

[RN]메일보내기 라이브러리 (react-native-mail)

by -제이리 2023. 3. 28.
728x90
320x100

리액트 네이티브에서 메일을 편리하게 보낼 수 있는 라이브러리가 있다.

이 라이브러리를 사용하면 사용자의 메일어플(예: 지메일)을 통해 바로 메일을 보낼 수 있다.

  

react-native-mail

 

설치방법

npm i --save react-native-mail

 

사용방법

import React from 'react';
import { Button } from 'react-native';
import Mailer from 'react-native-mail';

const SendMail = () => {

  const handleSendMail = () => {
    Mailer.mail({
      subject: 'Test Email',
      recipients: ['recipient1@example.com', 'recipient2@example.com'],
      ccRecipients: ['recipient3@example.com'],
      bccRecipients: ['recipient4@example.com'],
      body: '<b>This is a test email</b>',
      isHTML: true,
    }, (error, event) => {
      if (error) {
        // 에러 처리
        console.log('Error sending email:', error);
      } else {
        // 메일이 전송되었을 때 처리
        console.log('Email sent successfully');
      }
    });
  }

  return (
    <Button title="Send Email" onPress={handleSendMail} />
  );
}

export default SendMail;

 

 

https://github.com/chirag04/react-native-mail

 

GitHub - chirag04/react-native-mail: A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android

A wrapper on top of MFMailComposeViewController from iOS and Mail Intent on android - GitHub - chirag04/react-native-mail: A wrapper on top of MFMailComposeViewController from iOS and Mail Intent o...

github.com

 

728x90
320x100

댓글