-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mail multiple attacment support adding and version migration from 0.4…
….5.3 to 0.4.5.4
- Loading branch information
1 parent
a905d39
commit b5d45ae
Showing
15 changed files
with
126 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package io.robe.mail; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import javax.activation.FileDataSource; | ||
import javax.mail.AuthenticationFailedException; | ||
import javax.mail.MessagingException; | ||
import java.util.HashMap; | ||
|
||
/** | ||
* Created by hasanmumin on 05/01/16. | ||
*/ | ||
public class MailSenderTest { | ||
private MailSender mailSender; | ||
|
||
@Before | ||
public void initialize() { | ||
|
||
/** | ||
mail.smtp.username: username@robe.io | ||
mail.smtp.password: xxXXXXxx | ||
mail.smtp.host: smtp.gmail.com | ||
mail.smtp.port: 587 | ||
mail.smtp.auth: true | ||
mail.smtp.starttls.enable: true | ||
*/ | ||
|
||
HashMap<String, Object> properties = new HashMap<>(); | ||
properties.put("mail.smtp.username", "YOURGMAILACCOUNT"); | ||
properties.put("mail.smtp.password", "YOURPASSWORD"); | ||
properties.put("mail.smtp.host", "smtp.gmail.com"); | ||
properties.put("mail.smtp.port", 587); | ||
properties.put("mail.smtp.auth", true); | ||
properties.put("mail.smtp.starttls.enable", true); | ||
|
||
MailConfiguration mailConfiguration = new MailConfiguration(); | ||
mailConfiguration.setUsernameKey("mail.smtp.username"); | ||
mailConfiguration.setPasswordKey("mail.smtp.password"); | ||
mailConfiguration.setProperties(properties); | ||
|
||
mailSender = new MailSender(mailConfiguration); | ||
|
||
} | ||
|
||
@Test | ||
public void sendMail() { | ||
|
||
MailItem mailItem = new MailItem(); | ||
mailItem.setTitle("Title"); | ||
mailItem.setBody("body"); | ||
mailItem.setReceivers("receiver1", "receiver2"); | ||
mailItem.getAttachments().add(new FileDataSource("file1path")); | ||
mailItem.getAttachments().add(new FileDataSource("file2path")); | ||
|
||
try { | ||
mailSender.sendMessage(mailItem); | ||
} catch (MessagingException e) { | ||
e.printStackTrace(); | ||
if (e instanceof AuthenticationFailedException) { | ||
// TODO ignore this because Username and Password not accepted. | ||
assert true; | ||
} | ||
|
||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters