Sending email using jxl - java

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.

Related

Send email using "on behalf of" using apache common Email

I want to send email from my application by adding "on behalf of" address. Currently I am using apache common Email to send email and it seems I couldn't specify sender in there. As I can see email headers I need to set different values for sender and from to show email receive as "on behalf of" in the mail client.
Can anyone please help me to do this using java email client or can I achieve this using same apache common client? Solution needs to be work with most of common email clients like outlook, gmail etc..
As per link
you can do
msg.addHeader("Sender", "My Friend <xxxxxx#xxxxx.com>");

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

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.

How to send emails using Google App Engine Mail Service?

I want to be able to send emails out from my GAE app.
My personal email is registered with the permission "Is Owner"
I am using this as the from email following the example on this page.
https://cloud.google.com/appengine/docs/java/mail/
I tried sending the email with my application deployed to GAE.
I get an error message and getting the following exception
java.net.SocketException: Permission denied: Attempt to access a blocked recipient without permission.
I am just trying send a dummy email to test it out.
Also if I eventually get this working and I want to use some generic purpose email like admin#mydomain.com, how do I achieve this?
The problem is in the recipient's email. You are trying to send to a blocked address (probably something generic like test#example.com). Try changing the recipient's address to something else
As to your second question, you can only send email from admin emails or addresses ending in: #appid.appspotmail.com
So if you want to send from admin#mydomain.com you should add it to your admins of the apps (of course, the email must be a google account)

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 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