Closed hendisantika closed 7 months ago
I tried like this but still error.
@GetMapping
public String sendEmail() {
ApiClient defaultClient = Configuration.getDefaultApiClient();
ApiKeyAuth apiKey = (ApiKeyAuth) defaultClient.getAuthentication("api-key");
apiKey.setApiKey("API_KEY");
TransactionalEmailsApi apiInstance = new TransactionalEmailsApi();
SendSmtpEmail sendSmtpEmail = new SendSmtpEmail();
SendSmtpEmailSender sendSmtpEmailSender = new SendSmtpEmailSender();
sendSmtpEmailSender.setEmail("no-reply@jvm.my.id");
sendSmtpEmailSender.setName("JVM ID");
sendSmtpEmail.setSender(sendSmtpEmailSender);
SendSmtpEmailTo to = new SendSmtpEmailTo();
to.setEmail("hendi@yopmail.com");
to.name("HENDI");
sendSmtpEmail.setTo(List.of(to));
sendSmtpEmail.setSubject("Testing Send Email");
sendSmtpEmail.setTextContent("Testing");
SendSmtpEmailReplyTo replyTo = new SendSmtpEmailReplyTo();
replyTo.setEmail("no-reply@jvm.my.id");
replyTo.setName("JVM ID");
sendSmtpEmail.setReplyTo(replyTo);
sendSmtpEmail.setTags(List.of("dev"));
Map<String, Object> params = new HashMap<>();
params.put("username", "naruto");
sendSmtpEmail.setParams(params);
try {
CreateSmtpEmail result = apiInstance.sendTransacEmail(sendSmtpEmail);
log.info(String.valueOf(result));
} catch (ApiException e) {
log.error("Exception when calling TransactionalEmailsApi#sendTransacEmail");
e.printStackTrace();
}
return "Email Sent " + LocalDateTime.now();
}
Any suggestion?
Thanks
Error like this:
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Mar 20 15:34:57 WIB 2024
There was an unexpected error (type=Internal Server Error, status=500).
Class okio.Options does not have member field 'okio.Options$Companion Companion'
java.lang.NoSuchFieldError: Class okio.Options does not have member field 'okio.Options$Companion Companion'
at okhttp3.internal.Util.<clinit>(Util.kt:70)
at okhttp3.OkHttpClient.<clinit>(OkHttpClient.kt:1073)
at sendinblue.ApiClient.<init>(ApiClient.java:80)
at sendinblue.Configuration.<clinit>(Configuration.java:18)
at id.my.hendisantika.brevo.BrevoApplication.sendEmail(BrevoApplication.java:44)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:259)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:192)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:118)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:920)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:830)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1089)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:979)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1014)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:903)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:564)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:885)
at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:658)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:205)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:116)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:174)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:149)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:482)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:115)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:344)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:391)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:896)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1744)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:52)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:63)
at java.base/java.lang.Thread.run(Thread.java:1583)
How to send an email?
I didn't see any send email function on your README file.
Thanks