how to send mail to localhost - java

I am using smtp protocol to send email via gmail . I want to send mail to localhost . What address I will give for localhost to get that email ?

What is localhost in this case? Your local desktop or a server?
The only way gmail is going to be able to send mail to it, is if you've got an SMTP server running there and it has an IP that's accessible from the Internet.

You can only send to localhost from a mail server running on localhost. Generally though you'd need an Internet domain for this instead.

Related

Is it possible to track the smtp host by code in java?

I need that the application be able to track the smtp host by the email account, because it have to be capable to work with any mail account.
There is a way to do this?
Short answer is: no you can't.
To some degree you can get a smtp host from an email address, but not all email providers have an smtp server, and most email providers will require user specific authentication when using their smtp servers.
It's still possible to send mail from your computer when your email provider doesn't provide an smtp server because most Internet providers also provide you with an smtp server. You can't determine this smtp server based on someone's emailadres.
If your application always has to be able to send mail I would look into a free smtp server somewhere, or host your own.

Suddenly not able to send email by amazon SES - unable to connect smtp host

I am using Amazon SES from almost 4 months with same code, same port number(25) everything same. But from past 1 week I am not able to send email - while sending this error comes:
The email was not sent.
Error message: Could not connect to SMTP host: email-smtp.us-east-1.amazonaws.com, port: 25
I am using the same code for sending email that amazon suggests to use from link (http://docs.aws.amazon.com/ses/latest/DeveloperGuide/send-using-smtp-java.html)
We are working on a website project and using it inside it. Its not a problem with me alone, my team members of 4 working under same internet gateway, all of them are not able to send email from 1 week from their localhost.
But when we deploy the same code on Amazon ec2, top-level domain say sample.com then it starts working but when we deploy the same code under a sub-domain say beta.sample.com then again same error starts coming.
Does anyone have any idea about this?
Passing outgoing SMTP (25) port connections bloc
Try sending your email via email-smtp.us-east-1.amazonaws.com:587.
Outgoing connections to SMTP (25) port may be blocked by a firewall to stop outgoing spam.
Can you telnet any of the two ports? Do you get SMTP greeting messages?
telnet email-smtp.us-east-1.amazonaws.com 25
telnet email-smtp.us-east-1.amazonaws.com 587
https://en.wikipedia.org/wiki/Mail_submission_agent
Many Internet service providers and enterprise or institutional networks restrict the ability to connect to remote MTAs on port 25. The accessibility of a Mail Submission Agent on port 587[1] enables nomadic users to continue to send mail via their preferred submission servers even from within others' network

User registration mail using any email id

I have a registration page on my site. The users who register in my site, I want to send them a verification mail. I am able to send ail using my gmail id. But when I use my site mail id say www.xyz.com then mail is not getting sent please suggest me how to get it done.
First of all make sure your mail server is running, and if it linux server then grep your email ID from logs what you found as below: Replace Your#emailid with your email ID.
For exim:
grep YOUR#emailid /var/log/exim_mainlog
In Sendmail:
grep your#emailID /var/log/maillog
If you can send mails using the G-mail, then there is no issue with your script. As you are having issue with your own mail server or mail address, Make sure that exim or any other mail server is running on the server.
Also the domain say xyz.com is pointing to the server if it is having a MX as local domain.
For checking A record dig +trace xyz.com .Make sure that A record is points to the server.
For checking MX record dig +trace xyz.com MX . Make sure that MX is like "0 or 10 xyz.com"
Instead if it is using remote MX then make sure that you are using mail server IP as the remote mail server in the script.
Try sending mails using webmail client and make sure that there are no current issues with the mail mail server. like poor reputation or else.
In case domain is having remote MX, make sure that the your server IP is not listed in the firewall block of remote server.

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.

Sending email in Java

I have read that to send email in Java I need to obtain my ISP's SMTP address, but if I am intending to host my web app online, will this be my hosts ISP SMTP address?
EDIT: So I need to find out my clients ISP's SMTP address and send via this?
JavaMail is the built-in API for e-mail.
Ask your ISP if the host runs sendmail or equivalent locally (the web server host). It may be an advantage to hand off to sendmail as early as possible. In other words, try "localhost" as the SMTP server name.
Why? JavaMail is a simple SMTP client. It doesn't deal with DNS MX records. It doesn't have a built-in capability to queue mail if the SMTP server is unavailable. There's the default Java infinte DNS cache so that a DNS change to the SMTP host won't register with your app (tunable, but one more tuning to do). These are things that a local sendmail (or equivalent) process will do.
So if you can hand off the e-mail to a local sendmail/equivalent, that may improve e-mail delivery reliability. Assuming the local sendmail works, of course. It's how we configure some in-house apps that uses JavaMail to send mail and fixed all the above problems.
No, unless your webhost is the same as your ISP or your webhost also offers SMTP services.
In response to your edit, yes you need your ISP's SMTP address by the sound of things.
It will be the SMTP address you want to forward email through.
If you want to send email through your ISP account then it will be that SMTP.

Categories