Closed fanatic75 closed 4 years ago
Can you provide your code? It's not happening on me. Also which platform, which RN version and which react-native-smtp-mailer version are you using?
"react-native": "0.58.6", "react-native-smtp-mailer": "^1.1.10", buildscript { ext { buildToolsVersion = "28.0.2" minSdkVersion = 16 compileSdkVersion = 28 targetSdkVersion = 27 supportLibVersion = "28.0.0" } repositories { google() jcenter() maven { url 'https://maven.fabric.io/public' } } dependencies { classpath 'com.android.tools.build:gradle:3.2.0' classpath 'com.google.gms:google-services:4.0.1' // Google Services plugin classpath 'com.google.firebase:firebase-plugins:1.1.5' classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
subprojects {
project.configurations.all { resolutionStrategy.eachDependency { details -> if (details.requested.group == 'com.android.support' && !details.requested.name.contains('multidex') ) { details.useVersion "28.0.0" } } } } }
allprojects { repositories { mavenLocal() google() jcenter() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url "$rootDir/../node_modules/react-native/android"
}
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
}
}
task wrapper(type: Wrapper) { gradleVersion = '4.7' distributionUrl = distributionUrl.replace("bin", "all") }
Your js code calling the sendMail?
sendMail(){
if(this.state.message.length>20&&this.state.subject.length>10){
this.setState({
loading:true,
})
RNSmtpMailer.sendMail({
mailhost: "smtp.gmail.com",
port: "465",
ssl: true,
username: "support@dyfolabs.com",
password: "**********",
from:auth.currentUser.email,
recipients:"support@dyfolabs.com",
subject:this.state.subject,
htmlBody:"<p>"+this.state.message+"</p>",
attachmentPaths: [],
attachmentNames: [],
attachmentTypes: []
})
.then(success=>{
this.setState({loading:false});
alert("Message sent successfully. We will respond you within next 2 working days. Thank you for your patience.");
})
.catch(err=>{
this.setState({loading:false});
alert("Could not send message due to some error. Please contact us through our helpline Number. "+err);
});
}
so when I send the mail, I get the mail from support@dyfolabs.com only not from the email address written in from field.
And you're sure you've logged the auth.currentUser.email
just before and verified it contains the correct email address?
Yes, I have even tried changing it to string "a@gmail.com" but it still sends email from support@dyfolabs.com
Okay not i got the problem. You can't send an email using your smtp but then set "from" address another address without this email address permission. You 'll need to add this address as an alias and this address should verify that you can send from that address using the above smtp. For example on gmail smtp, if you follow the steps in this article, you'll be able to set another from address. Probably something similar should exist on dyfolabs. Correct me if i'm wrong on how it is working
I can't get access from the other mail as it's not mine, it's supposed to be my user's mail. What I want to do is to get them to mail us for support from the app itself. But looks like that won't be possible without their permission, right? Also can you please comment over the other issue I have with your library. I'm unable to use this library with proguardrelease true which is essential for the app.
I have a related question. Is there a way to set a custom fromName and not just the email address displayed?
I have got issue in my production build.. still after adding progaurd rules send mail not working without any warning or error pls help if any one have same issue
@ManishBorkar could you open a new issue describing with details your problem?
error:535-5.7.8 Username and password not accepted. this type of error is occuring while send an email using react-native-smtp-mailer
@angelos3lex this is my code
sendEmail = () => { RNSmtpMailer.sendMail({ mailhost: "smtp.gmail.com", port: "465", ssl: true, //if ssl: false, TLS is enabled,note: in iOS TLS/SSL is determined automatically, so either true or false is the same username: "vshrimali432@gmail.com", password: "*****", Authentication: 'OAuth2', from: "harshitashrimali980@gmail.com", recipients: "vshrimali709@gmail.com", subject: "hello testing", htmlBody: "
body
", attachmentPaths: ["pathToFile1.png","pathToFile2.txt","pathToFile3.csv"], attachmentNames: ["image.jpg", "firstFile.txt", "secondFile.csv"],//only used in android, these are renames of original files. in ios filenames will be same as specified in path. In ios-only application, leave it empty: attachmentNames:[] attachmentTypes: ["img", "txt", "csv"]//needed for android, in ios-only application, leave it empty: attachmentTypes:[] }) .then(success => alert(success)) .catch(err => alert(err)); };in release v1.2.4, the fromName
works as expected, and you can also use the replyTo
field in case you want the recipient to reply to another address than the host's.
The from field in sendMail({ from : ""}) doesn't work.