javax.mail is not sending mail to external domains in certain scenarios - java

I am using javax.mail API for sending the mails in a web application, where I am able to send the email to all domains.
In the same application, I am exposing a webservice which will accept the input data and send a email with an attachment. I am using the same code for sending the mails. But, the email is sending only to the internal domain users(Ex: username#mydomain.com) .The email is not sent to external domains (Ex:username#gmail.com/username#yahoo.com) .
Kindly help me if anybody knows what could be the reason.Please let me know if you need any additional information.

The SMTP relay host is restricting the email which are sent from email address with other domain names(From Address Ex:uesrname#gmail.com / uesrname#yahoo.com) to an external domain. After using a valid from address(username#mydomain.com), I am able to send email to external domain as well.

Related

Sending email using jxl

I have a query in which I need to send email from my email id to a large group of people.
I have an excel file, which contains email address of people across the world with several domain names. I am reading these email and trying to send it but I get the error stating "cannot send email"
Probably I am using wrong SMTP names.
However when I send email to people in my domain, I am able to do so.
I want to have the same "From" address and different "To" address. Please let me know if this is possible.
e.g From: address#somedomain.com
To: address#other domain.com
Regards
Bipul
Yes, this is possible. Normally all the messages would be sent to your smtp server, which would forward them to the appropriate mail server for the recipient's domain. Your smtp server may be rejecting some of the messages if it's not configured to allow you to relay messages outside your domain. Possibly it won't let you do this because you haven't authenticated to your mail server.

Is it possible to use 2-way email relay on GAE?

I have a web application running on google appengine which sends emails to users, giving them an another users email address so that they can contact each other. I would like to hide the real email addresses using a temporary one so the real email addresses remain private. Similar to the way that is done on craiglist when you send an email to an ad. Is there way to achieve this on appengine? I'm using javax.mail. Thanks.
You can use AppEngine to both send and receive emails. So you can receive emails and re-send them to different addresses hiding the original address. Of course there are restrictions.
Official docs for sending emails: Using JavaMail to Send Mail
Official docs for receiving email: Receiving Email
To send emails the sender address must be one of the following types:
The address of a registered administrator for the application
The address of the user for the current request signed in with a Google Account. You can determine the current user's email address with the Users API. The user's account must be a Gmail account, or be on a domain managed by Google Apps.
Any valid email receiving address for the app (such as xxx#APP-ID.appspotmail.com).
Your app can receive email at addresses of the following form:
string#appid.appspotmail.com
Email messages are sent to your app as HTTP POST requests using the following URL:
/_ah/mail/<address>
where address is a full email address, including domain name. To handle incoming email in your app, you have to map email URLs to servlets in the web.xml file.

Send mail (Java vs Php)

I have developed an app with a login. To help users I would like to send a mail reminding their credentials.. 2 solutions but 2 problems:
1) If I send the mail from the mobile phone (using my gmail account and mail.jar library) Google always reports a possible violation of my account or a suspect access, blocking it. I read several forum page about remove this feature but some people say that Gmail is built to be used by a single person
2) If I send a mail from a php page (using the function mail($mailto,$subject,$message,$header) several mail server put automatically this email into the trash folder.
Any suggestion? How to solve this issue?
Thank you in advance
You could send mail in java (mail.jar or mailServices of Spring Framework). I suggest you to use a mail provider service to send mail. It's better because there many things to care with when you send email ( email does not exist, delay of receiving the email, the current status of email sent, received or read...)

is it possible to Send e-mail without e-mail server? [duplicate]

This question already has an answer here:
Is SMTP server required to send mail through web server, by using JavaMail API?
(1 answer)
Closed 8 years ago.
JavaMail sends e-mails using an e-mail server, typically through the SMTP interface of an e-mail provider. Is it necessary to use an e-mail server to send e-mails?
I have a web site that will send e-mails and if possible I'd like to send the e-mails directly from the web site code without using an e-mail server. The JavaMail FAQ says that an e-mail server is required.
Is there a way to send e-mails without using an e-mail server, either with JavaMail or another API?
You need an e-mail server. When you send an email from your address to another address. you are really sending it to a mail server. The protocol used to send to the server is (usually) SMTP.
You can deliver an email directly to one of the SMTP servers mentioned in the MX record of the address's domain. Usually that is a bad idea,though:
Delivering the mail to a local server is fast - you can almost immediately continue and do something else and let the server handle the delivery.
The actual delivery can take some time, for instance the remote mail server might be slow. Or it might reject the mail first - it is a known strategy against spam to tell a sender to try sending a mail a second time, which some spam bots won't do.
Also the mail server can easily try again a day later or so when the remote server is down, this reduces risk of lost mail.
i found using google SMTP as easy way to send mail.

send mail using java api

i have requirement that i need to send/receive email after successful login by user, upon click on email verification i will activate the user . i dont have dedicated smtp server for send/receive mails for this requirement. right now i am looking for free service for initial start up options , i gone through this http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/ for sending email through gmail. my question is can i receive mail using gmail smtp service?
Short answer: No, not with SMTP. But probably with IMAP/POP.
Long answer: SMTP is only used for sending email between MTAs (Mail Transfer Agent). You'll have to download the email from your email provider, google in this case, using IMAP or POP.
You'll have to connect and check regularly as without an MTA service on your end, you can't get email pushed to you. Most personal ISPs block outbound port 25 so setting up a MTA might be tricky as you have to figure out your providers SMTP relay (if they even have one!)
See here for enabling IMAP/POP support for gmail:
https://support.google.com/mail/troubleshooter/1668960?hl=en
Google will find you a suitable imap/pop client library to use with java.
Edit:
If you are doing a regular e-mail verification step for a website registration, you don't need to receive an e-mail from the user. You send them an e-mail with a a link to your websites verification URL. The link contains a predetermined ID, say the sha1 sum of username + e-mail encoded into the URL. The user clicks the link and opens a specific page on your site where you verify the ID when the page is loaded. This is how it is usually done. This way you don't need to receive any email programmatically.
Unless receiving it by email is a specific requirement from your customer, in which case you can ignore this edit. :)

Categories