I am trying to send emails with react-native-smtp-mailer with attached images. The attachmentPaths is an array is a state which is updated dynamically but when I try to send the email I receive error Attachmentpaths cannot be cast from string to readable array . This is my code.
RNSmtpMailer.sendMail({
mailhost: 'smtp.gmail.com',
port: '465',
ssl: true, // optional. if false, then TLS is enabled. Its true by default in android. In iOS TLS/SSL is determined automatically, and this field doesn't affect anything
username: 'email@gmail.com',
password: 'password',
fromName: 'Ssadd', // optional
replyTo: 'email@gmail.com', // optional
recipients: 'email1@gmail.com,email2@gmail.com',
subject: 'subject',
htmlBody: '<h1>header</h1><p>body</p>',
attachmentPaths: JSON.stringify(this.state.paths), //
attachmentNames: JSON.stringify(this.state.filenames), // required in android, these are renames of original files. in ios filenames will be same as specified in path. In a ios-only application, no need to define it
}).then((success) => console.log(success));
};
this.state.path is an array and also this.state.filenames I tried the code without JSON.stringify but then I receive email with attachments but they are empty and the file size is 0