javax.mail

Exception to fix javax.mail.AuthenticationFailedException exception

谁都会走 提交于 2019-12-02 13:33:55
问题 I am learning how to send an email with javamail API, i have created the necessary properties and instructions to send a simple email using SMTP server, and i am using this code : Properties props=new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); Session session= Session

Exception to fix javax.mail.AuthenticationFailedException exception

試著忘記壹切 提交于 2019-12-02 07:17:33
I am learning how to send an email with javamail API, i have created the necessary properties and instructions to send a simple email using SMTP server, and i am using this code : Properties props=new Properties(); props.put("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); Session session= Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication

Prefetch preview text from JavaMail Message

折月煮酒 提交于 2019-12-01 21:54:37
I'm using JavaMail 1.5.2 to read messages from IMAP accounts. To reduce the number of requests to the host I prefetch some message data, like From, Date, Message-ID etc.: Folder folder = store.getFolder("inbox"); folder.open(Folder.READ_ONLY); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE); fp.add(FetchProfile.Item.CONTENT_INFO); fp.add("Message-ID"); Message msgs[] = folder.getMessages(); folder.fetch(msgs,fp); However, I want to also prefetch some parts of the content to create a preview text for the mail without having to load the full message with all attachments.

javax.mail.AuthenticationFailedException Java Mail

对着背影说爱祢 提交于 2019-12-01 04:47:33
I have made a little program that send a message to my email account. Most of my code seems to work fine. However, I have encounter the AuthenticationFailedException when I am my code hit transport.send in my program. I am not sure why because I think I have everything set up correctly. Here is my code. JavaEmail.java public static void main (String[] args) throws Exception{ //intialize logger protected static Logger logger = LogManager.getLogger(JavaEmail.class.getName()); //smtp related parameters private static String smtpUseremail; private static String smtpReceiverEmailAddress; private

javax.mail.AuthenticationFailedException Java Mail

左心房为你撑大大i 提交于 2019-12-01 02:51:18
问题 I have made a little program that send a message to my email account. Most of my code seems to work fine. However, I have encounter the AuthenticationFailedException when I am my code hit transport.send in my program. I am not sure why because I think I have everything set up correctly. Here is my code. JavaEmail.java public static void main (String[] args) throws Exception{ //intialize logger protected static Logger logger = LogManager.getLogger(JavaEmail.class.getName()); //smtp related

Sending mail: java.net.SocketException: Network is unreachable: connect

半世苍凉 提交于 2019-11-30 08:48:48
Try send mail via javax.mail: Properties props = new Properties(); props.put("mail.smtp.host", "xxxxx"); props.put("mail.smtp.port", "25"); props.put("mail.smtp.auth", "false"); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("xx", "xx"); } }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("xxxxx")); message.setRecipients(Message.RecipientType.TO, InternetAddress.parse("xxxxx")); message.setSubject("Subject"); message.setText(

Sending mail: java.net.SocketException: Network is unreachable: connect

北战南征 提交于 2019-11-29 12:43:51
问题 Try send mail via javax.mail: Properties props = new Properties(); props.put("mail.smtp.host", "xxxxx"); props.put("mail.smtp.port", "25"); props.put("mail.smtp.auth", "false"); Session session = Session.getInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("xx", "xx"); } }); try { Message message = new MimeMessage(session); message.setFrom(new InternetAddress("xxxxx")); message.setRecipients

javax.mail.AuthenticationFailedException: failed to connect, no password specified?

你离开我真会死。 提交于 2019-11-29 06:15:00
This program attempts to send e-mail but throws a run time exception: javax.mail.AuthenticationFailedException: failed to connect, no password specified? Why am I getting this exception when I have supplied the correct username and password for authentication? Both the sender and receiver have g-mail accounts. The sender and the receiver both have g-mail accounts. The sender has 2-step verification process disabled. This is the code: import javax.mail.*; import javax.mail.internet.*; import java.util.*; class tester { public static void main(String args[]) { Properties props = new Properties()

Setting the from name in a javax.mail.MimeMessage?

流过昼夜 提交于 2019-11-28 06:43:23
Currently, our application uses a javax.mail to send email, using javax.mail.MailMessage. We set the From headers of the email this way: Message msg = new MimeMessage(mailSession); msg.setFrom(new InternetAddress("mail@companyxyz.com")); This works just fine, but we'd like to make the "From" section a little more user-friendly. Currently, someone receiving an email will see "mail@companyxyz.com" in the "From" section of their inbox. Instead, we'd like them to see "Company XYZ" there. I figure this is probably done with the addHeader() method, but I'm not sure what the header name would be.

package javax.mail and javax.mail.internet do not exist

孤街浪徒 提交于 2019-11-28 06:09:43
When I compile a simple code that has the following 2 import statements: import javax.mail.* import javax.mail.internet.* I get the following message: package javax.mail does not exist package javax.mail.internet does not exist Why do I get this error? Here is the code I have: import javax.mail.*; import javax.mail.internet.*; import java.util.*; class tester { public static void main(String args[]) { Properties props = new Properties(); props.put("mail.smtp.com" , "smtp.gmail.com"); Session session = Session.getDefaultInstance( props , null); String to = "me@gmail.com"; String from = "from