[GH-ISSUE #999] Incomplete email address in email headers #793

Closed
opened 2026-02-26 01:31:55 +03:00 by kerem · 6 comments
Owner

Originally created by @psss on GitHub (Dec 18, 2019).
Original GitHub issue: https://github.com/jberkel/sms-backup-plus/issues/999

Originally assigned to: @kurahaupo, @psss on GitHub.

After updating my settings to use apps password instead of xoath I've noticed that the email headers to and from contain only the first part of my email address (before the @ character). Other email addresses are stored correctly. It would be nice to use a complete email address for the account owner as well. It allows to easily use gmail filters like from:me when searching for messages.

Expected behaviour

Complete email address included in message headers, e.g. user@example.com

Actual behaviour

Only the login part included, e.g. user

Steps to reproduce the behaviour

Configure imap using password, backup messages.

Thanks for this great app!

Originally created by @psss on GitHub (Dec 18, 2019). Original GitHub issue: https://github.com/jberkel/sms-backup-plus/issues/999 Originally assigned to: @kurahaupo, @psss on GitHub. After updating my settings to use apps password instead of xoath I've noticed that the email headers `to` and `from` contain only the first part of my email address (before the `@` character). Other email addresses are stored correctly. It would be nice to use a complete email address for the account owner as well. It allows to easily use gmail filters like `from:me` when searching for messages. ### Expected behaviour Complete email address included in message headers, e.g. `user@example.com` ### Actual behaviour Only the login part included, e.g. `user` ### Steps to reproduce the behaviour Configure imap using password, backup messages. Thanks for this great app!
kerem 2026-02-26 01:31:55 +03:00
Author
Owner

@kurahaupo commented on GitHub (Dec 19, 2019):

Use your full email address as your Gmail login ID.

<!-- gh-comment-id:567336015 --> @kurahaupo commented on GitHub (Dec 19, 2019): Use your full email address as your Gmail login ID.
Author
Owner

@kurahaupo commented on GitHub (Dec 19, 2019):

(This should probably be included in the documentation.)

<!-- gh-comment-id:567336373 --> @kurahaupo commented on GitHub (Dec 19, 2019): (This should probably be included in the documentation.)
Author
Owner

@psss commented on GitHub (Dec 19, 2019):

I've already tried to use the full email address for the login in imap settings. But it did not help.

<!-- gh-comment-id:567443235 --> @psss commented on GitHub (Dec 19, 2019): I've already tried to use the full email address for the login in imap settings. But it did not help.
Author
Owner

@kurahaupo commented on GitHub (Dec 19, 2019):

I won't say absolutely that this is a problem that's specific to your set-up, but it does seem odd that nobody else has reported this problem.

Tracing through the code, I see that the sender and recipient fields in a new email message are set in app/src/main/java/com/zegoggles/smssync/mail/MessageGenerator.java at lines 91-99:

        if (Telephony.TextBasedSmsColumns.MESSAGE_TYPE_INBOX == messageType) {
            // Received message
            msg.setFrom(record.getAddress(addressStyle));
            msg.setRecipient(Message.RecipientType.TO, userAddress);
        } else {
            // Sent message
            msg.setRecipient(Message.RecipientType.TO, record.getAddress(addressStyle));
            msg.setFrom(userAddress);
        }

where userAddress is set in the constructor for class MessageGenerator, when called from app/src/main/java/com/zegoggles/smssync/mail/MessageConverter.java at lines 81-89:.

    messageGenerator = new MessageGenerator(context,
                                            new Address(userEmail),
                                            preferences.getEmailAddressStyle(),
                                            new HeaderGenerator(referenceUid, App.getVersionCode(context)),
                                            personLookup,
                                            preferences.getMailSubjectPrefix(),
                                            allowedIds,
                                            new MmsSupport(context.getContentResolver(), personLookup),
                                            preferences.getCallLogType(),
                                            preferences.getDataTypePreferences());

where userEmail is set in the constructor for class MessageConverter, when called from
app/src/main/java/com/zegoggles/smssync/service/BackupTask.java at line 74:

    this.converter = new MessageConverter(context,
                                          service.getPreferences(),
                                          authPreferences.getUserEmail(),
                                          personLookup,
                                          contactAccessor);

where getUserEmail is defined in app/src/main/java/com/zegoggles/smssync/preferences/AuthPreferences.java at lines 136-142:

    public String getUserEmail() {
        if (getAuthMode() == AuthMode.PLAIN) {
            return getImapUsername();
        } else {
            return getOauth2Username();
        }
    }

and getImapUsername is defined at lines 232-234

    public String getImapUsername() {
        return preferences.getString(IMAP_USER, null);
    }

Or in short, changing your IMAP auth username to your full Gmail address should have worked. Please try again, and ensure that you restart the app.

Note that this will not change any messages that have already been recorded, and will only affect subsequent messages.

<!-- gh-comment-id:567488087 --> @kurahaupo commented on GitHub (Dec 19, 2019): I won't say absolutely that this is a problem that's specific to your set-up, but it does seem odd that nobody else has reported this problem. Tracing through the code, I see that the sender and recipient fields in a new email message are set in _app/src/main/java/com/zegoggles/smssync/mail/MessageGenerator.java_ at lines 91-99: ```java if (Telephony.TextBasedSmsColumns.MESSAGE_TYPE_INBOX == messageType) { // Received message msg.setFrom(record.getAddress(addressStyle)); msg.setRecipient(Message.RecipientType.TO, userAddress); } else { // Sent message msg.setRecipient(Message.RecipientType.TO, record.getAddress(addressStyle)); msg.setFrom(userAddress); } ``` where `userAddress` is set in the constructor for class `MessageGenerator`, when called from _app/src/main/java/com/zegoggles/smssync/mail/MessageConverter.java_ at lines 81-89:. ```java messageGenerator = new MessageGenerator(context, new Address(userEmail), preferences.getEmailAddressStyle(), new HeaderGenerator(referenceUid, App.getVersionCode(context)), personLookup, preferences.getMailSubjectPrefix(), allowedIds, new MmsSupport(context.getContentResolver(), personLookup), preferences.getCallLogType(), preferences.getDataTypePreferences()); ``` where `userEmail` is set in the constructor for class `MessageConverter`, when called from _app/src/main/java/com/zegoggles/smssync/service/BackupTask.java_ at line 74: ```java this.converter = new MessageConverter(context, service.getPreferences(), authPreferences.getUserEmail(), personLookup, contactAccessor); ``` where `getUserEmail` is defined in _app/src/main/java/com/zegoggles/smssync/preferences/AuthPreferences.java_ at lines 136-142: ```java public String getUserEmail() { if (getAuthMode() == AuthMode.PLAIN) { return getImapUsername(); } else { return getOauth2Username(); } } ``` and `getImapUsername` is defined at lines 232-234 ```java public String getImapUsername() { return preferences.getString(IMAP_USER, null); } ``` Or in short, changing your IMAP auth username to your full Gmail address should have worked. Please try again, and ensure that you restart the app. Note that this will not change any messages that have already been recorded, and will only affect subsequent messages.
Author
Owner

@psss commented on GitHub (Dec 20, 2019):

Thanks for detailed investigation. It seems that during my second attempt the old messages with wrong headers have been restored from trash instead of new messages created with correct headers. After deleting the wrong messages and cleaning up the trash everything seems to be working fine. Thanks much for your help.

<!-- gh-comment-id:567880570 --> @psss commented on GitHub (Dec 20, 2019): Thanks for detailed investigation. It seems that during my second attempt the old messages with wrong headers have been restored from trash instead of new messages created with correct headers. After deleting the wrong messages and cleaning up the trash everything seems to be working fine. Thanks much for your help.
Author
Owner

@kurahaupo commented on GitHub (Dec 20, 2019):

Glad I could help.

<!-- gh-comment-id:568128710 --> @kurahaupo commented on GitHub (Dec 20, 2019): Glad I could help.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/sms-backup-plus-jberkel#793
No description provided.