My gmail smtp in my grails application is working fine on windows but not working when it comes to ubuntu machine with same configuration.
Configuration used by me are:
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "*******#gmail.com"
password = "*********"
props = ["mail.smtp.auth":"false", "mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false" ]
}
Install and configure Sendmail on Ubuntu
This should help you get Sendmail installed with basic configuration on Ubuntu.
If sendmail isn't installed,
install it:
sudo apt-get install sendmail
Configure /etc/hosts file:
nano /etc/hosts
3.Make sure the line looks like this:
127.0.0.1 localhost yourhostname
4.Run Sendmail's config and answer 'Y' to everything:
sudo sendmailconfig
Restart apache:
sudo service apache2 restart.
To check the status send of sendmail service
1: For start:
service sendmail start.
For restart:
service sendmail restart
3.Check the status :
service sendmail status
The correct configuration is the following, I have used it without any instalations, on Ubuntu, MacOS and Windows:
grails {
mail {
host = "smtp.gmail.com"
port = 465
username = "your#email.es"
password = "yourpassword"
props = ["mail.smtp.auth":"true",
"mail.smtp.socketFactory.port":"465",
"mail.smtp.socketFactory.class":"javax.net.ssl.SSLSocketFactory",
"mail.smtp.socketFactory.fallback":"false"]
}
}
Related
I have a gRPC server written in Java and I'm currently trying to create a web client, with React. However, I can't seem to manage the connection between the envoy proxy to which the client is connecting and the actual server.
I would expect to receive the same message as with the Java client, but I get the error "Http response at 400 or 500 level", receiving an empty response with the web client, while the Java server doesn't even get the request.
The server runs on port 8080, and the envoy proxy is configured on port 9090, which is the one used by the web client.
Dockerfile:
FROM envoyproxy/envoy-dev:latest
COPY ./envoy.yaml /etc/envoy/envoy.yaml
CMD /usr/local/bin/envoy -c /etc/envoy/envoy.yaml -l trace --log-path /tmp/envoy_info.log
envoy.yaml:
admin:
access_log_path: /tmp/admin_access.log
address:
socket_address: { address: 0.0.0.0, port_value: 9901 }
static_resources:
listeners:
- name: listener_0
address:
socket_address: { address: 0.0.0.0, port_value: 9090 }
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: local_service
domains: ["*"]
routes:
- match: { prefix: "/" }
route:
cluster: m_service
cors:
allow_origin:
- "*"
allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout
expose_headers: grpc-status,grpc-message
enabled: true
http_filters:
- name: envoy.grpc_web
- name: envoy.cors
- name: envoy.router
clusters:
- name: m_service
connect_timeout: 0.25s
type: logical_dns
http2_protocol_options: {}
lb_policy: round_robin
hosts:
socket_address:
address: localhost
port_value: 8080
The commands I use for building and running the docker container are docker build -t m-server ., and docker run -p 9090:9090 -td m-server /bin/bash and the proto classes for the front-end are loaded statically.
If there's any more code that'd be useful to post, please let me know. Any advice is appreciated, thank you!
For me the solution was to change the command passed to run the container, thus docker run -p 9090:9090 -td m-server /bin/bash becoming docker run -d -p 9090:9090 -p 9901:9901 m-server. The main difference was putting -d instead of -td and the second port mapping is for the envoy server.
I am just learning Docker and from what I understood from the documentation, the explanation would be that I was running the container in detached mode, but with a pseudo-tty allocated, which is used in foreground mode. I've seen it here but the purpose was slightly different and at the time I misunderstood it as only keeping the container running was not what I needed.
Changing 'localhost' to '0.0.0.0', as suggested in this answer is also important.
Looks like Envoy is not forwarding the request to your Java server. Envoy has an admin interface https://www.envoyproxy.io/docs/envoy/latest/operations/admin . That and the Envoy log files should help troubleshoot this.
socket_address:
address: localhost
This is the problem. Your envoy tries to forward to itself if it's running as dockerized image, because localhost is not your docker host machine for running container (where grpc server is running) , but actually localhost of running container. Use docker compose, port mapping or external network. Good luck
I have jenkins installed on my windows desktop and having issues configuring it to send emails from my outlook account as it uses TLS instead of SSL. I have done some research and some forums suggested adding the JENKINS_JAVA_OPTIONS to the jenkins.xml file and doing a restart however this didn't work for me.
JENKINS_JAVA_OPTIONS -Djava.awt.headless=true -Dmail.smtp.starttls.enable=true
My SMTP settings are
SERVER smtp-mail.outlook.com
SMTP PORT 587
Use SSL unchecked
Username *****
Password ******
Error is below
com.sun.mail.smtp.SMTPSendFailedException: 530 5.7.0 Must issue a STARTTLS command first
at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:2057)
at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:1580)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1097)
at javax.mail.Transport.send0(Transport.java:195)
at javax.mail.Transport.send(Transport.java:124)
at hudson.tasks.Mailer$DescriptorImpl.doSendTestMail(Mailer.java:581)
at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source)
at org.kohsuke.stapler.Function$MethodFunction.invoke(Function.java:343)
at org.kohsuke.stapler.Function.bindAndInvoke(Function.java:184)
You can configure jenkins configuration file to enable TLS. For ubuntu it is in the path /etc/default/jenkins.
Use following statement to do so.
JAVA_ARGS = "-Djava.awt.headless=true -Dmail.smtp.starttls.enable=true"
it worked for me. good luck.
I am using undertow for my applications with docker.
I am able to do the following
create fat jar
create docker image from that
Run that docker image
Listing on 8080 and added EXPOSE 8080 in Docker file
curl my url from INSIDE the CONTAINER , curl localhost:8080/sample
I am facing some weird problem,
And My compose file is
version: '2'
services:
login:
image: my-image
ports:
- "8080:8080"
with 8080 port I am not able to access the url.
My Dockerfile
FROM openjdk:8-jre
COPY ./target/*-with-dependencies.jar /jars/service-jar.jar
EXPOSE 8080
CMD java -cp /jars/service-jar.jar my.Main
My Undertow Listener
Undertow server = Undertow.builder()
.addHttpListener(8080, "localhost")
.setHandler(path)
.build();
I got some link in google still not able to make it work
http://lists.jboss.org/pipermail/undertow-dev/2014-October/000999.html
fixed the issue , by listening the ip to the docker containers ip address .
I changed my listener to
Undertow server = Undertow.builder()
.addHttpListener(8080, InetAddress.getLocalHost().getHostAddress())
.setHandler(path)
.build();
Now it working fine.
"The external IP is something completely different. So in summary you
must set the host server for undertow as the Internal IP in the
Iptables created by docker"
I missed to read this line in my reference link (http://lists.jboss.org/pipermail/undertow-dev/2014-October/000999.html).
My boss find out that .
How are you running your docker image?
Are you publishing port?
docker run -p 8080:8080 ...
Related documentation
I'm trying to setup SSL for embedded Tomcat. Both connectors starts but I only get response on http. On https I get in chrome a "No data received message" when I try http://localhost:9000/
The port is open:
I've tried telnet
telnet localhost 9000
and I have a connection.
I've also tried
openssl s_client -connect localhost:9000
and GET / method
and my servlet prints me the expected result in console. I do not understand why I get this error in browsers(chrome and Firefox)
My OS is Ubuntu 14.04 and I've tried with both Java 7 and Java 8 having the same result. Tomcat version is 8.0.23 from Maven repo
The code is:
public class Main {
public static void main(String[] args) throws Exception {
Tomcat tomcat = new Tomcat();
Service service = tomcat.getService();
service.addConnector(getSslConnector());
File base = new File(System.getProperty("java.io.tmpdir"));
Context rootCtx = tomcat.addContext("/", base.getAbsolutePath());
Tomcat.addServlet(rootCtx, "emptyServlet", new EmptyServlet());
rootCtx.addServletMapping("/*", "emptyServlet");
tomcat.start();
tomcat.getServer().await();
}
private static Connector getSslConnector() {
Connector connector = new Connector();
connector.setPort(9000);
connector.setSecure(true);
connector.setScheme("https");
connector.setAttribute("keyAlias", "tomcat");
connector.setAttribute("keystorePass", "password");
connector.setAttribute("keystoreType", "JKS");
connector.setAttribute("keystoreFile",
"keystore.jks");
connector.setAttribute("clientAuth", "false");
connector.setAttribute("protocol", "HTTP/1.1");
connector.setAttribute("sslProtocol", "TLS");
connector.setAttribute("maxThreads", "200");
connector.setAttribute("protocol", "org.apache.coyote.http11.Http11AprProtocol");
connector.setAttribute("SSLEnabled", true);
return connector;
}
}
The keystore you can find it on github
I've already tried different keystores but with the same result. Also the keystore looks good: keytool -list -keystore keystore.jks seems to be as expected.
Thanks in advance
It turned out to be my fault. The service was up and running but I kept on trying on http://localhost:9000 not https://locahost:9000 in my browser
I'm trying following progam:
If i use SUDO java to run everthing is fine, but I don't want to use
SUDO
without SUDO i get following error: SocketException: Permission Denied (as its PORT 80)
Using jetty documentation, I get this to work using command line where i change
jetty-setuid.xml -- Put user-name is non-root user
start.ini -- Change to EXEC and passing etc/jetty-setuid.xml as first parameter
jetty.xml -- To have port number as 80
then I still do sudo as non-root user -- like -> sudo java -jar start.jar
Jetty starts on port 80 as non-root user.
I want to ACHIEVE the same using JAVA Program. Any help/comments are appreciated.
package my.package;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.handler.ResourceHandler;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
public class JettyTest {
public static void main(String[] args) throws Exception
{
Server server = new Server();
System.out.println("Created new server, now going to start");
SelectChannelConnector connector0 = new SelectChannelConnector();
connector0.setPort(80); //on port 80
connector0.setMaxIdleTime(30000);
connector0.setRequestHeaderSize(8192);
server.setConnectors(new Connector[]{ connector0 });
server.setHandler(new MyHandler()); //simple hello world handler
server.start();
System.out.println("started server on port 80");
server.join();
}
}
You must use sudo somehow on Unix to elevate to root priviledges. Otherwise you cannot get port 80.
For Java programs, the sudo must be applied to the java command itself, but it is generally a bad idea to do that.
A more conservative solution is to bind to another port, say 8080, and then reroute port 80 to that port. The commands to do so varies wildly between operating systems and may not even exist on some older Unix-versions.
Sudo elevates the privileges of your command to root level. The reason why you need to "sudo" here (or, more generally speaking, run the command as root) is the fact that in Linux the ports below 1024 are reserved to root.
In other words - you cannot run jetty (or any other service) on port 80 if you're not root.
The simplest solution here is to run Jetty on another port (8080 is a common one).
If you still want users to access the service on the default port, consult http://wiki.eclipse.org/Jetty/Howto/Port80 and http://docs.codehaus.org/display/JETTY/port80 .