@Override
    protected boolean protocolConnect(String host, int port, String awsAccessKey,
            String awsSecretKey) {
        if (isConnected())
            throw new IllegalStateException("Already connected");

        if (isNullOrEmpty(awsAccessKey) || isNullOrEmpty(awsSecretKey)) {
            if (isNullOrEmpty(accessKey) || isNullOrEmpty(secretKey)) {
                // Use the no-argument constructor to fall back on:
                // - Environment Variables
                // - Java System Properties
                // - Instance profile credentials delivered through the Amazon EC2 metadata service
                this.emailService = new AmazonSimpleEmailServiceClient();
            }
            awsAccessKey = this.accessKey;
            awsSecretKey = this.secretKey;
        }

        if (this.emailService == null) {
            // Use the supplied credentials.
            this.emailService = new AmazonSimpleEmailServiceClient(new BasicAWSCredentials(awsAccessKey, awsSecretKey));
        }

        if (!isNullOrEmpty(host)) {
            this.emailService.setEndpoint(host);
        } else if (this.httpsEndpoint != null) {
            this.emailService.setEndpoint(this.httpsEndpoint);
        }
        super.setConnected(true);
        return true;
    }
@ Override protected boolean protocolConnect ( String host , int port , String awsAccessKey , String awsSecretKey ) { if ( isConnected ( ) ) throw new IllegalStateException ( "Already connected" ) ; if ( isNullOrEmpty ( awsAccessKey ) || isNullOrEmpty ( awsSecretKey ) ) { if ( isNullOrEmpty ( accessKey ) || isNullOrEmpty ( secretKey ) ) { this . emailService = new AmazonSimpleEmailServiceClient ( ) ; } awsAccessKey = this . accessKey ; awsSecretKey = this . secretKey ; } if ( this . emailService == null ) { this . emailService = new AmazonSimpleEmailServiceClient ( new BasicAWSCredentials ( awsAccessKey , awsSecretKey ) ) ; } if ( ! isNullOrEmpty ( host ) ) { this . emailService . setEndpoint ( host ) ; } else if ( this . httpsEndpoint != null ) { this . emailService . setEndpoint ( this . httpsEndpoint ) ; } super . setConnected ( true ) ; return true ; }
Sets up a new AmazonSimpleEmailServiceClient. This method is typically called
indirectly from the connect() method and should only be called on
instantiation or to reopen after a close(). If a non-null or empty User
and Password passed in session properties are overridden while user
remains connected (mail.aws.user and mail.aws.password). The default
https endpoint is specified by the mail client; however, it can be
overridden by either passing in a value or setting mail.aws.host. Like
the user and password, the variable that is passed in takes preference
over the properties file.

@param host
Optional - host specifies the AWS E-mail endpoint
@param awsAccessKey
Optional - AWS Access Key (otherwise must specify through
properties file)
@param awsSecretKey
Optional - AWS Secret key (otherwise must specify through
properties file)
@return Returns true if non-empty credentials are given