Subversion Repositories javautils

Rev

Rev 3 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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