Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mail-service not woking #79

Closed
mohitbaskota opened this issue Aug 4, 2015 · 2 comments
Closed

Mail-service not woking #79

mohitbaskota opened this issue Aug 4, 2015 · 2 comments
Assignees

Comments

@mohitbaskota
Copy link

Hello

I am trying to run the vertx mail-service examples. The verticle gets started but the mail is not being sent.

Following is what i am doing in a start method of a verticle

MailConfig mailConfig = new MailConfig()
.setHostname("smtp.gmail.com")
.setPort(465)
.setStarttls(StartTLSOptions.REQUIRED)
.setLogin(LoginOption.REQUIRED)
.setAuthMethods("PLAIN")
.setUsername("abc@abc.com")
.setPassword("abc");

    MailClient mailClient = MailClient.createShared(vertx, mailConfig);

    MailMessage email = new MailMessage()
            .setFrom("user1@example.com")
            .setTo("abc@abc.com")
            .setSubject("Test email with HTML")
            .setText("this is a message")
            .setHtml("<a href=\"http://vertx.io\">vertx.io</a>");

    mailClient.sendMail(email, result -> {
        if (result.succeeded()) {
            System.out.println(result.result());
        } else {
            System.out.println("got exception");
            result.cause().printStackTrace();
        }
    });
}

When sendMail is called, its handler is never called. no action is performed.

@cescoffier cescoffier self-assigned this Aug 7, 2015
@cescoffier
Copy link
Member

your configuration is wrong. To send a mail from Gmail, use:

MailConfig mailConfig = new MailConfig()
        .setHostname("smtp.gmail.com")
        .setPort(465)
        .setSsl(true)
        .setLogin(LoginOption.REQUIRED)
        .setAuthMethods("PLAIN")
        ....

@Dylancorbus
Copy link

private static MailClient getEmailClient() {
config.setHostname("smtp.gmail.com");
config.setPort(465);
config.setSsl(true);
config.setLogin(LoginOption.REQUIRED);
config.setUsername("xxx");
config.setPassword("xxx");
config.setAuthMethods("PLAIN");
mailClient = MailClient.createShared(vert, config);
eMessage.setFrom("xxx@gmail.com");
eMessage.setTo("xxx@gmail.com");
eMessage.setSubject("Test email");
eMessage.setText("this is the plain message text");
eMessage.setHtml("this is html text <a href="http://vertx.io\">vertx.io");
return mailClient;
}

exception on connect
javax.net.ssl.SSLHandshakeException: Failed to create SSL connection

i tried this and it keeps throwing this exception

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants