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

app crashed when loggedin user trying to replay any mail for first time #16

Open
PrantikMondal opened this issue Feb 21, 2020 · 0 comments

Comments

@PrantikMondal
Copy link

0

I am using react-native-mailcore library to reply mail. As per the instruction on that library doc, i am doing smtp login before calling MailCore.sendMail. From second time reply mail is working fine with same code as well as For compose mail i am using same code to send mail. It is working fine for that case also. My code is given bellow.

import MailCore from 'react-native-mailcore';
var LocalStorage = require('react-native-local-storage');

sendMail = async () => {
let user = await LocalStorage.get('user');
await MailCore.loginSmtp({
hostname: 'smtp.gmail.com',
port: 465,
username: user.email,
password: user.password,
}).catch(error => ToastAndroid.show(error,ToastAndroid.LONG))
// All the values from the state are coming correctly
let subject = this.state.subject || '(No Subject)';
let body = this.state.compose + this.state.body || '';
let from = {
addressWithDisplayName : this.state.name,
mailbox: this.state.user,
}
let to = {[this.state.to] : 'to labels'};

// App crashed here while called sendMail

await MailCore.sendMail({
  headers:{
    isEncrypted: 'true',
  },
  from:from,
  to:to,
  subject:subject,
  body,  
}).then(()=>{
    this.goBack(); //navigating to main page after success
    ToastAndroid.show("sending...",ToastAndroid.SHORT);
}).catch(err => ToastAndroid.show(err,ToastAndroid.LONG));

}

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