Thunderbird api to send a mail via Java - java

I have been using Java mail API to send mails generated through the Java program. What I want to do now is to send a mail through Thunderbird mail client so that the mail get saved to the sent items folder of the user and the user can resend a mail if it has failed.
I also would like to know if it's possible to get a delivery report in the Java mail API.
Edit
I found out that our mail server is POP3 and it doesn't store mail. So is it a good idea to send another mail to the sender as well and define a rule that categorize those messages?

even if you send it with the java mail api (well gmail at least), you will still be able to see in the sent folder using thunderbird. as a matter of fact, 5 minutes ago, I saw this using a website that I build. I am sending emails using Java API, and when I check the send folder I can see them.

The InBox / Outbox in Thunderbird are normally mapped ti your IMAP-Account. The IMAP-Account is set on a mail server. All your mails and folders are stored on that mail server. the client (Thunderbird) only shows the contant from the server. By remote calls (IMAP-protocol) you can create/delete/edit/move folders and mails on the server. Sending a mail is not part of IMAP. Here you use the SMTP-Protocol. When you configure a mailaccount in Thunderbird you must configure IMAP & SMTP. When you send a mail Thunderbird does the following steps:
- Send Mail by SMTP-Protocol
- Create Mail in Outbox by IMAP-Protocol
SMTP & IMAP are totally different. But if you want to send a mail and see this mail in your outbox you must use both. You can program the same workflow with the java mail api.

If I get your question right, you are looking for a way to trigger mail sending via Mozilla Thunderbird from a Java program (an external program / software running on the same local machine).
You can achieve that via different methods:
calling the Thunderbird binary with command-line arguments
via SimpleMAPI, which Thunderbird supports
via XPCOM, also built into Thunderbird
What you won't be able to achieve easily is getting feedback from Thunderbird about the outcome of triggering / prompting the user to send a mail. But you could achieve that by using more difficult ways of integrating Thunderbird with your external software:
read and parse the actual MBOX inbox / mail sent / profile files in a user's profile. "using the X-Mozilla-Status headers (you could) figure out if a message is a new message (etc). A mbox file is essentially just a flat text file that has a seperator between the messages" (parentheses by me, source)
Write a bridging WebExtension Thunderbird Add-On that integrates in some way with your software. An extension has, via Thunderbird's WebExtensions API, essentially a hook for every feature Thunderbird has and your code Add-On could expose these internals in some way to your software.
AFAIK and sadly Thunderbird, as it ships, exposes no API or similar interface out of the box.

Related

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.

Best way to send an E-Mail from a java Application

I've been searching for the best way to send an e-mail with an attachment by my java application. I want to use this as an users bug report with logger files. The recipient should be my own e-mail address. I'd prefer the use of an e-mail client.
I tried the following:
Send an e-mail with user authentification like this. I don't want to use this, because the user would need to reveal his e-mail account and password. Furthermore, I'd have to set the properties for every e-mail adress, which is impossible.
Send an e-mail directly to my own e-mail address like this in Listing 16.16 (didnt found an english example). The problem is every e-mail server is using POP authentification nowadays, that means the recipient e-mail server won't accept my e-mail.
Using the mailto URL syntax like this. Doesn't work aswell, because the attachment function isn't working properly in every e-mail client. Best solution so far is to brief the user to add the attachment by himself, after I would put it to his desktop. Or upload the data and add a link to the e-mail body.
The last way I've found is this one. As you could assume this won't work either, because the localhost needs to be connected to the internet and capable enough to send an e-mail.
Hopefully I explained my problem well enough. Is there a different way to send bug reports?
The generally accepted way to get around the problems you describe is to keep all the email logic server side, and then have your application call a web service with the appropriate parameters. It's pretty easy to knock a PHP script / servlet up that will do the job and then send the results on via email, put them in a mysql database or so on.
However, if you can't / don't want to / won't keep this server side, I'd recommend using JavaMail to create a MimeMessage, then using writeTo() to write this to an EML file.
You can then do the usual:
Desktop.getDesktop().open(emlFile);
...which will open the EML file with the default application for handing those files, which is almost always the mail client. Still not foolproof, but if you're determined on sending the email from the client directly I think that's as good as you'll get.

Be able to send an email to an email address, and have that appear on a web page

I want to be able to send an email to an email address, and then have it appear on a web page. Is this possible?
My guess is you'd have to write your own email server, something which I am not capable of doing. So I am assuming this won't be possible for me.
But if there is some way it can be done, that would be great. I generally program in Java and use Tomcat as my app server.
No, you wouldn't have to run your own SMTP server. You'd simply need to be able to retrieve mail from a POP3 or IMAP server, using something like the mail client API found in javax.mail.
It would be up to you to decide how much control you'd give to users. For example, who specifies the IMAP settings? Who decides which messages to fetch and display? Maybe that's all pre-configured. Maybe you write full-featured, web-based email client that can send messages as well as retrieve. This is all determined through the design of your web application.
You don't need to write your own mail server. You can use an ordinary (external) mail server and poll its inbox via POP3 or IMAP from your software. This introduces a short delay up to the full poll interval, but that might or might not be acceptable for you.
I can't give you a good tip for a email client lib to use for that, though.
Here is a simple example of sending email trough Google's SMTP server.

Java GroupWise Mail Client

Is anyone aware of a way to retrieve and send mails by talking directly to the GroupWise server.
I want to be able to retrieve mail using Java if possible.
I wrote a Outlook Plug-In that retrieved mail out of GroupWise via the Groupwise Outloop Plug-in (If that makes sense).
Then dropped the message in a directory where I retrieved it with a Java App.
The problem is that I cannot add more than one GroupWise account in Outlook and need to.
I had a look at this question, but would like to know if there is a Java API
that will allow me to retrieve/send mail from the GroupWise server in a JavaMail like manner.
Thanks.
GroupWise allows mails to be retrieved using IMAP and POP3 which are standard supported by JavaMail. (And outlook too for that matter)
Sending mail should also be possible using smtp.
If it is for plain email I prefer to use these basic proptocols like smtp, pop3 and imap because they work almost everywhere, anytime and on any platform. They are less feature rich than the proprietary protocols, but that point is often not very relevant since many of these features are only meaningful for a subset of the mailclients out there.

Categories