not getting mail from Java application using smtp - java

I have a java application which send mail using SMTP,but recently a modified its property file and restarted my tomcat server [although property change is a password change and is not related to smtp ].
now it is not sending mails :(
I checked my smtp server and tried to send mail from it.It is sending.
Any idea what went wrong?
any help would be appreciated
thanks in advance

Your SMTP server logs should tell you whether something was sent to it, and why it didn't relay the email.
If your change was password related, an authentication error may be the cause.
I would look at the following first:
Which credentials is your Java application using to send requests to the SMTP server?
Then, are these credentials still accepted on the server?
Finally, most SMTP servers will have a separate list of either included or excluded source IPs, from where to accept message requests, see if your Java app's source machine is allowed there.

Related

Use Javamail through a proxy

I have a Java application which uses Javamail (v.1.5.4) for send and review mails into a POP/SMTP mail server. This application must run in our coporate network, where we have a proxy (f*ck!) that blocks my requests. I have googled possible solutions and Javamail says that we can use SOCKS5:
Q: How do I configure JavaMail to work through my proxy server? [updated!]
A: JavaMail does not currently support accessing mail servers through a web proxy server. One of the major reasons for using a proxy server is to allow HTTP requests from within a corporate network to pass through a corporate firewall. The firewall will typically block most access to the Internet, but will allow requests from the proxy server to pass through. In addition, a mail server inside the corporate network will perform a similar function for email, accepting messages via SMTP and forwarding them to their ultimate destination on the Internet, and accepting incoming messages and sending them to the appropriate internal mail server.
That solution is not valid for me, so I have to look for new alternatives. Some people say that they implements a custom SocketFactory, but I am not sure if that is enough. Someone has tried?
Another possible solution could be use another library, but I don't find anything that could avoid this proxy.
Has anyone treat this problem? How do you solve it?
Summary
Problem: I have to send and read e-mails in a Java application, but my proxy blocks the requests.
What I have tried? Using javamail, I have tried to use SOCKS5 solution, but with no effect.
What I am looking for? A way to avoid this proxy. Someone tells about a custom SocketFactory(but I am not sure if this is valid). I don't find any alternative to Javamail.
Regards!!
Actually JavaMail does support SOCKS proxy, just not authenticated proxies.
That solution is not valid for me
But you don't explain why.
There's another way of configuring Java Mail with SOCKS proxy (even authenticated one) that doesn't involve configuring your own socket factory. There's an open source library called Simple Java Mail (full disclosure: I maintain it), which is really simple to use:
new Mailer(
new ServerConfig("smtp.host.com", 587, "user#host.com", "password"),
TransportStrategy.SMTP_TLS,
new ProxyConfig("socksproxy.host.com", 1080, "proxy user", "proxy password")
).sendMail(email);
However, if your proxy is actually an HTTP proxy, you're out of luck and you will need to resort to something like Corkscrew or connect.
Although it's not a programmatic solution, the cleanest way would be to check if your company has an internal mail server and use that one to send your emails. It doesn't require using SOCKS or proxies, just configuration.
A nice side-effect may be that emails sent in name of your company are also sent by your company. If the mail administrators have set-up SPF records correctly, it greatly reduces the risk of your emails ending up in someone's junk / spam folder.
Using your own mail server is generally the best solution, but if you don't have your own mail server the JavaMail FAQ describes other solutions, such as using Corkscrew or connect to work through your web proxy server.
As per the latest release of Javamail API 1.6.2 , JavaMail supports accessing mail servers through a web proxy server and also authenticating to the proxy server. See my answer here stackoverflow.com/questions/36278073/how-to-let-javamail-support-http-proxy/52855090#52855090

Local SMTP server for ubuntu

I'm using a Java class that sends mails using JavaMail. I really need to use it even though authentication is not yet implemented. Basically it just has SMTP hostname, port, from, to, subject and body.
I need a SMTP server for it. Most of the ones I've tried use authentication.
Does anyone know maybe a local smtp server for ubuntu?
It doesn't have to be very complex/secure because it's just a proof of concept.
Something like sending a text email from my gmail account to my yahoo account. Thanks

How to use javamail to connect to ms exchange webmail?

I checked that I am not able to access the pop 3 port and imap port. I think I can only access via https webmail.
So for this case how do I actually connect to the microsoft exchange server and read the emails inside using java mail can anyone provide any specific code samples to achieve this?
Connecting to Exchange via OWA sounds like its going to be difficult; here's a post which deals with at least the authentication side of things.
In any event, you can connect to an Exchange server via IMAP if the IMAP service is turned on. Check with your server admin to confirm the service is running. If it is running, see this other post for how to set connection parameters.

Java mail: sending email without SMTP

I want to send an email without using SMTP protocol. Is that possible to implement using Java? Since, my remote machine does not have access to google, yahoo and other accounts. and even my office mail can not be configured using SMTP server due to some security issues. Is any other way to send an email from remote machine.
The JavaMail section at java.sun.com lists many third party products that plugin to the JavaMail API. Hopefully one of those will fit your needs but I can't be more specific because you don't say what non-SMTP sending options you have open to you.
You could setup Your own SMTP server on remote machine, IMHO, it is better than incorporate it into program directly.
I want to send an email without using
SMTP protocol. Is that possible to
implement using Java?
With Java you can implement any Layer-5 network protocol.
ALL mail servers using SMTP to receive messages. At any time you have to connect with SMTP to the destination mail server.
If you cannot get out from local network to the Internet with some services you will need a proxy or network tunnel to connect the destination.

Send postfix mail to Java application running on Tomcat

I have a Postfix mail server, and I want to forward my received emails to my application written in Java and running on a Tomcat web server.
As far as I know, it is possible to forward the whole email (head, body, everything) to a port on localhost, where both the mail server and my application is running.
But I don't have any idea how to achieve this. I assume to a http server like Tomcat I cannot send this data in plain (postfix does not wrap it into a http package), so maybe I have to write another daemon process to receive the data from postfix, wrap it into http, and send this to my application?
I'm a bit confused, and have never been a specialist of protocols and these kind of things.
Please someone explain how can I solve the problem above!
Thank you in advance,
Balázs

Categories