Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sending an email with attachments using 'react-native-mail' library works but didn't receive email #195

Open
jieunyu0623 opened this issue Dec 5, 2022 · 0 comments

Comments

@jieunyu0623
Copy link

I have a React Native app (Only for IOS) and I implemented a feature where user can share a pdf file via email using the Mail app on ios devices. I used 'react-native-mail' library for this feature and it works great. However, there was one person who said that it did send an email but didn't get an email. Checked spam folder and tried everything we could to find an email. Thought it was an issue with email credentials so we tried with a brand new gmail account but still didn't get an email.

Let me explain how this library works first. You need to set up a gmail account (has to be gmail to get this library to work) in Settings on your ios device (if there are multiple gmail accounts, only the first one is used as a sender for the react-native-mail library.) Then activate mail app with this email account. Go to the app then enter a recipient then send an email with any attachments (for my case, a small pdf file.) then we get an email on the recipient gmail account!

I could be sure an email is sent because when I get the event, it says 'sent'. I tried to reproduce the issue that person had but there was no luck. Here's my code snippet below.

const sharePdf = async () => {
    Mailer.mail(
      {
        subject: 'Assessment Report',
        recipients: [currentUser.email ? currentUser.email : ''],
        body: 'Assessment Report',
        isHTML: true,
        attachments: [
          {
            path: reportUri,
            type: 'pdf',
            name: 'Report',
          },
        ],
      },
      (error, event) => {
        console.log('error => ', error);

        if (error === 'not_available') {
          Alert.alert(
            'Please add a Gmail (Google) account to your iPad',
            'Go to settings > Mail > accounts > Add Account > Google',
            [
              {
                text: 'OK',
                onPress: () => console.log('OK: Email Error Response'),
              },
            ],
            {cancelable: true},
          );
        } else {
          Alert.alert(
            event,
            error,
            [
              {
                text: 'Ok',
                onPress: () => console.log('OK: Email Error Response'),
              },
            ],
            {cancelable: true},
          );
        }
      },
    );
  };

please help me if anyone has faced this issue or has an idea of fixing this issue..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant