Subversion Repositories javautils

Rev

Rev 9 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. package de.viathinksoft.utils.mail.sender;
  2.  
  3. import javax.mail.MessagingException;
  4.  
  5. import de.viathinksoft.utils.mail.EMailAddress;
  6. import de.viathinksoft.utils.mail.InvalidMailAddressException;
  7.  
  8. public class PlainTextMailSender extends RawMailSender {
  9.        
  10.         // --- E-Mail-Adressobjekt benutzen (dekodiert automatisch den Punycode)
  11.        
  12.         public void setMailFrom(String mailFrom) throws InvalidMailAddressException {
  13.                 this.setMailFrom(new EMailAddress(mailFrom));
  14.         }
  15.  
  16.         public void setMailFrom(EMailAddress mailFrom) throws InvalidMailAddressException {
  17.                 if (mailFrom == null) throw new InvalidMailAddressException();
  18.                 super.setMailFrom(mailFrom.getMailAddressPunycodedDomain());
  19.         }
  20.  
  21.         public void setRecipient(String recipient) throws InvalidMailAddressException {
  22.                 this.setRecipient(new EMailAddress(recipient));
  23.         }
  24.  
  25.         public void setRecipient(EMailAddress recipient) throws InvalidMailAddressException {
  26.                 if (recipient == null) throw new InvalidMailAddressException();
  27.                 super.setRecipient(recipient.getMailAddressPunycodedDomain());
  28.         }
  29.        
  30.         // --- PlainText Implementieren
  31.        
  32.         private String message;
  33.  
  34.         public String getMessage() {
  35.                 return message;
  36.         }
  37.  
  38.         public void setMessage(String message) {
  39.                 this.message = message;
  40.                 if (this.message == null)
  41.                         this.message = "";
  42.         }
  43.  
  44.         protected void generateMailObject() throws MessagingException,
  45.                         AuthentificateDataIncompleteException {
  46.  
  47.                 super.generateMailObject();
  48.                
  49.                 msg.setContent(message, "text/plain");
  50.         }
  51.  
  52. }
  53.