Skip to content

Verifier system to check the validity of the email inserted by the user. This system works with James Apache service as SMTP server

License

Notifications You must be signed in to change notification settings

N7ghtm4r3/Monkey

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Monkey

v1.0.0

Verifier system to check the validity of the email inserted by the user. This system works with James Apache service as SMTP server

Implementation

Add the JitPack repository to your build file

Gradle

  • Add it in your root build.gradle at the end of repositories

    Gradle (Short)

    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }

    Gradle (Kotlin)

    repositories {
        ...
        maven("https://jitpack.io")
    }
  • Add the dependency

    Gradle (Short)

    dependencies {
        implementation 'com.github.N7ghtm4r3:Monkey:1.0.0'
    }

    Gradle (Kotlin)

    dependencies {
        implementation("com.github.N7ghtm4r3:Monkey:1.0.0")
    }

Maven

  • Add it in your root build.gradle at the end of repositories
<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
  • Add the dependency
<dependency>
    <groupId>com.github.N7ghtm4r3</groupId>
    <artifactId>Monkey</artifactId>
    <version>1.0.0</version>
</dependency>

🛠 Skills

  • Java

Usages

SMTP server configuration

Linux based

You need to download the Linux zip folder and then extract it.

To launch the SMTP service you need to run the shell script in:

james-server-spring-app-3.8.0
    |-- bin
        |-- run.sh

Then at the first launch you will need to add a domain and a user to use SMTP server and the Monkey's service:

# Pathname of the script
james-server-spring-app-3.8.0
    |-- bin
        |-- james-cli.sh
        
# Add a domain
./james-cli.sh adddomain your_domain.any_first_level_domain # e.g -> monkey.tecknobit

# Add a user        
./james-cli.sh adduser user@your_domain.any_first_level_domain <user_password> # e.g [email protected] root

Windows based

You need to download the Windows zip folder and then extract it.

To launch the SMTP service you need to run the shell script in:

james-server-spring-app-3.8.0
    |-- bin
        |-- run.bat

Then at the first launch you will need to add a domain and a user to use SMTP server and the Monkey's service:

# Pathname of the script
james-server-spring-app-3.8.0
    |-- bin
        |-- james-cli.bat
        
# Add a domain
.\james-cli.bat AddDomain your_domain.any_first_level_domain # e.g -> monkey.tecknobit

# Add a user        
.\james-cli.bat AddUser user@your_domain.any_first_level_domain <user_password> # e.g [email protected] root

Note

If you will run the James Apache service on a machine with the SMTP service already integrated you will need to change the default ports value in the server configuration file to run correctly the James server, in the specific the bind property

james-server-spring-app-3.8.0
   |-- conf
       |-- smtpserver.xml # default value: 0.0.0.0:25
       |-- imapserver.xml # default value: 0.0.0.0:143
       |-- pop3server.xml # default value: 0.0.0.0:110

Tip

To use the James Apache SMTP with external providers such Gmail, Hotmail, etc... you need to change the default port value in:

james-server-spring-app-3.8.0
   |-- conf
       |-- smtpserver.xml # required port value: 0.0.0.0:465 or custom port value 0.0.0.0:any_other_port_value if is already in use the 465 value

Then you must set a Reverse DNS (rDNS) to be accepted by those providers, you can follow this guide for more information.

To use correctly the MonkeyVerifier you need to use the same value inserted also for the smtp_port argument.

Monkey workflow

Init the verifier

MonkeyVerifier monkeyVerifier = new MonkeyVerifier(
        "host_where_running_smtp_service", 
        smtp_port, // Default value: 25
        // NUMBERS, CHARACTERS or ALPHANUMERIC
        VerificationCodeType, 
        // FIVE_MINUTES, FIFTEEN_MINUTES, THIRTY_MINUTES, ONE_HOUR or ALWAYS_KEEP_VALID (is the dafault value)
        KeepEmailValid, 
        "[email protected]", 
        "root"
);

Plain verification email

monkeyVerifier.sendPlainVerificationEmail(
        "from_text", 
        "email_subject", 
        "email_body",
        "[email protected]", "[email protected]"
);

Verification email with the default Monkey template

// The colors scheme
MonkeyColorsScheme monkeyColorsScheme = new MonkeyColorsScheme(
        "the_primary_color_value",
        "the_secondary_color_value",
        "the_tertiary_color_value",
        "the_texts_color_value"
);

// The logo details
MonkeyLogo monkeyLogo = new MonkeyLogo(
        "link_to_open_when_the_logo_is_clicked",
        "url_of_the_logo_to_insert"
);

// The texts to use in the template
MonkeyTextTemplate monkeyTextTemplate = new MonkeyTextTemplate(
        "the_title_of_the_email_to_insert",
        "the_description_of_the_email_to_insert",
        "tag_for_the_text_of_the_email_footer_to_insert",
        "tag_for_the_reasons_text_why_the_email_was_sent"
);

// The template object to create the complete template
MonkeyTemplate monkeyTemplate = new MonkeyTemplate(
        monkeyColorsScheme,
        monkeyLogo,
        monkeyTextTemplate
);

// Send the verification email
monkeyVerifier.sendDefaultTemplateVerificationEmail(
        "from_text",
        "email_subject",
        monkeyTemplate,
        "[email protected]", "[email protected]"
);

Verification email with a custom template

monkeyVerifier.sendPlainVerificationEmail(
        "pathname_of_the_template",
        "from_text", 
        "email_subject", 
        "email_body",
        "[email protected]", "[email protected]"
);

Verify the code sent by the user

monkeyVerifier.verifyCodeSent(
        "email_of_the_user_to_check",
        "verification_code_sent_by_the_user",
        new MonkeyVerificationActions() {
            @Override
            public void onSuccess() {
                // The verification codes match -> ON_SUCCESS_WORKFLOW         
            }

            @Override
            public void onFailure() {
                // The verification codes don't match or 
                // the email is expired -> ON_FAILURE_WORKFLOW    
            }
        }
);

Authors

Support

If you need help using the library or encounter any problems or bugs, please contact us via the following links:

Thank you for your help!

Badges

Twitter

Donations

If you want support project and developer

Crypto Address Network
3H3jyCzcRmnxroHthuXh22GXXSmizin2yp Bitcoin
0x1b45bc41efeb3ed655b078f95086f25fc83345c4 Ethereum

If you want support project and developer with PayPal

Copyright © 2024 Tecknobit

About

Verifier system to check the validity of the email inserted by the user. This system works with James Apache service as SMTP server

Topics

Resources

License

Stars

Watchers

Forks