angelos3lex / react-native-smtp-mailer

Send emails by connecting to smtp server+attachments, using android javamail and ios mailcore2
39 stars 32 forks source link

Is possible to use reply-to #39

Closed RenanSanguinete closed 3 years ago

RenanSanguinete commented 3 years ago

Someone knows if is possible to use reply-to?

I need to somehow specify other email to reply insted the email indicated on to field.

RenanSanguinete commented 3 years ago

Based on solution on that issue https://github.com/shihabmridha/react-native-smtp/issues/3 I was able to solve it here.

If anyone is interesting on Android I change the RNSmtpMailerModule.java adding:

On sendEmail function add String replyTo = obj.getString("replyTo");

run function modify sender.sendMail(subject, body, from, recipients, bcc, attachmentPaths, attachmentNames, attachmentTypes, replyTo);

on MailSernder class

public synchronized void sendMail(String subject, String body, String sender, String recipients, ReadableArray bcc, ReadableArray attachmentPaths, ReadableArray attachmentNames, ReadableArray attachmentTypes, String replyTo) throws Exception { ....... message.setReplyTo(InternetAddress.parse(replyTo)); ...... }

iOS I change the RNSmtpMailer.m adding:

on sendMail method ... NSString replyToEmail = [RCTConvert NSString:obj[@"replyTo"]]; ... MCOAddress replyTo = [MCOAddress addressWithDisplayName:nil mailbox:replyToEmail]; ... [[builder header] setReplyTo:@[replyTo]]; ...

angelos3lex commented 3 years ago

@RenanSanguinete Thanks a lot for the provided solution. I intent to release a new version on the weekend, including this enhancement, TS support, #20 & #10 additions, and also to remove the necessity to provide all arguments, as more of them can be optional. If you wish to PR your solution till then, you're more than welcome!

RenanSanguinete commented 3 years ago

I see that PR #20 and after implement wasn't what I expected, so I implement myself base of the solution posted. I split the username from the user that is the key to login. So that way it's two separated information, that's the best for my case.

RenanSanguinete commented 3 years ago

@angelos3alex I tried to PR my modifications, but I get the 403 error on final step, git push. So I can copy and paste here both files if u want to check and merge after.

angelos3lex commented 3 years ago

You can fork this repo, then push your solution to your repo, and then PR it to this repo