Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package com.spice.profitmandi.common.mail;

/**
 * The two ways this system can send mail. There is no third.
 */
public enum MailSenderType {

    /**
     * Authenticates as sdtech@smartdukaan.com. Every message sent this way has its
     * From rewritten to that identity, because Google Workspace binds an
     * authenticated session to one address and refuses any other with
     * "535 Authorization failed: Authenticated user is not authorized to send mail".
     */
    GOOGLE,

    /**
     * Google Workspace relay. Does not authenticate at all — it is authorised by
     * allowlisted source IP — so it may legitimately send as noreply@.
     */
    RELAY;

    public static MailSenderType fromStored(String value) {
        if (GOOGLE.name().equals(value)) {
            return GOOGLE;
        }
        // Anything else is the relay, including rows written under labels that
        // no longer exist.
        return RELAY;
    }
}