|
|
|
Oracle 11 Mail API
|
|||
|---|---|---|---|
|
#18+
Добрый день(если день) Вопрос по сабжу. Есть класс SendMail (код ниже) В 10 оракле все работает . Перешли на 11 и при обращении к тому же SMTP серверу получаем javax.mail.SendFailedException: Sending failed; nested exception is: javax.mail.MessagingException: SMTP can only send RFC822 messages javax.mail.MessagingException: SMTP can only send RFC822 messages падает на строчке Transport.send(msg); В чем грабли? Я стащил javax.mail.jar с https://java.net/projects/javamail/pages/Home#Download_JavaMail_1.5.2_Release просто, чтобы проверить свой класс. Проверил класс в Eclipse - работает , а из под базы - не работает Я не знаю какой mail.jar находится в самой базе(кстати, как узнать какие jar стандартные в базе загружены?) ---------------------------------------------------------------------------------------- create or replace and compile java source named "SendMail" as import java.util.*; import java.io.*; import javax.mail.*; import javax.mail.internet.*; import javax.activation.*; public class SendMail { // Sender, Recipient, CCRecipient, and BccRecipient are comma-separated lists of addresses. // Body can span multiple CR/LF-separated lines. // Attachments is a ///-separated list of file names. public static int Send(String SMTPServer, String Sender, String Recipient, String CcRecipient, String BccRecipient, String Subject, String Body, int BodyType, String ErrorMessage[], String Attachments) { // Error status; int ErrorStatus = 0; Properties props = System.getProperties(); props.put("тратата", SMTPServer); props.setProperty("mail.transport.protocol", "smpt"); props.setProperty("mail.host", SMTPServer); props.setProperty("mail.user", ""); props.setProperty("mail.password", ""); Session session = Session.getDefaultInstance(props, null); try { // Create a message. MimeMessage msg = new MimeMessage(session); // extracts the senders and adds them to the message. // Sender is a comma-separated list of e-mail addresses as per RFC822. { InternetAddress[] TheAddresses = InternetAddress.parse(Sender); msg.addFrom(TheAddresses); } // Extract the recipients and assign them to the message. // Recipient is a comma-separated list of e-mail addresses as per RFC822. { InternetAddress[] TheAddresses = InternetAddress.parse(Recipient); msg.addRecipients(Message.RecipientType.TO,TheAddresses); } // Extract the Cc-recipients and assign them to the message; // CcRecipient is a comma-separated list of e-mail addresses as per RFC822 if (null != CcRecipient) { InternetAddress[] TheAddresses = InternetAddress.parse(CcRecipient); msg.addRecipients(Message.RecipientType.CC,TheAddresses); } // Extract the Bcc-recipients and assign them to the message; // BccRecipient is a comma-separated list of e-mail addresses as per RFC822 if (null != BccRecipient) { InternetAddress[] TheAddresses = InternetAddress.parse(BccRecipient); msg.addRecipients(Message.RecipientType.BCC,TheAddresses); } // Subject field msg.setSubject(Subject); // Create the Multipart to be added the parts to Multipart mp = new MimeMultipart(); // Create and fill the first message part { MimeBodyPart mbp = new MimeBodyPart(); if (BodyType == 1) mbp.setContent(Body, "text/html;\n charset=\"UTF-8\""); else mbp.setText(Body); // Attach the part to the multipart; mp.addBodyPart(mbp); } // Attach the files to the message if (null != Attachments) { int StartIndex = 0, PosIndex = 0; while (-1 != (PosIndex = Attachments.indexOf("///",StartIndex))) { // Create and fill other message parts; MimeBodyPart mbp = new MimeBodyPart(); FileDataSource fds = new FileDataSource(Attachments.substring(StartIndex,PosIndex)); mbp.setDataHandler(new DataHandler(fds)); mbp.setFileName(fds.getName()); mp.addBodyPart(mbp); PosIndex += 3; StartIndex = PosIndex; } // Last, or only, attachment file; if (StartIndex < Attachments.length()) { MimeBodyPart mbp = new MimeBodyPart(); FileDataSource fds = new FileDataSource(Attachments.substring(StartIndex)); mbp.setDataHandler(new DataHandler(fds)); mbp.setFileName(fds.getName()); mp.addBodyPart(mbp); } } // Add the Multipart to the message msg.setContent(mp); // Set the Date: header msg.setSentDate(new Date()); // Send the message; Transport.send(msg); } catch (MessagingException MsgException) { ErrorMessage[0] = MsgException.toString(); Exception TheException = null; if ((TheException = MsgException.getNextException()) != null) ErrorMessage[0] = ErrorMessage[0] + "\n" + TheException.toString(); ErrorStatus = 1; } return ErrorStatus; } // End Send Class } // End of public class SendMail / ---------------------------------------------------------------------------------------- create or replace FUNCTION JSendMail(SMTPServerName IN STRING, Sender IN STRING, Recipient IN STRING, CcRecipient IN STRING, BccRecipient IN STRING, Subject IN STRING, Body IN STRING, BodyType IN NUMBER, ErrorMessage OUT STRING, Attachments IN STRING) RETURN NUMBER IS LANGUAGE JAVA NAME 'SendMail.Send(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, java.lang.String[], java.lang.String) return int'; / ------------------------------------------------------------------------------------ create or replace FUNCTION SendMail(Sender IN STRING, Recipient IN STRING, CcRecipient IN STRING, BccRecipient IN STRING, Subject IN STRING DEFAULT ' ', Body IN STRING DEFAULT ' ', BodyType IN NUMBER DEFAULT 0, ErrorMessage OUT STRING, Attachments IN STRING) RETURN NUMBER IS v_mail_server мфксрфк2(2000); BEGIN select mail_server into v_mail_server from my_servers if v_mail_server is null then ErrorMessage := 'Mail Server is not defined'; RETURN(1); else RETURN JSendMail(v_mail_server, Sender, Recipient, CcRecipient, BccRecipient, Subject, Body, BodyType, ErrorMessage, Attachments); DBMS_OUTPUT.PUT_LINE('ErrorMessage is '|| ErrorMessage); DBMS_OUTPUT.PUT_LINE('After JSendMail'); end if; END SendMail; / ----------------------------------------------------------------------------------------------- ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 18.02.2015, 22:26:20 |
|
||
|
Oracle 11 Mail API
|
|||
|---|---|---|---|
|
#18+
jvsjvs, varchar2 ? Код: plsql 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88. 89. 90. 91. 92. 93. 94. 95. 96. 97. 98. 99. 100. 101. 102. 103. 104. 105. 106. 107. 108. 109. 110. 111. 112. 113. 114. 115. 116. 117. 118. 119. 120. 121. 122. 123. 124. 125. 126. 127. 128. 129. 130. 131. 132. 133. 134. 135. 136. 137. 138. 139. 140. 141. 142. 143. 144. 145. 146. 147. 148. 149. 150. 151. 152. 153. 154. 155. 156. 157. 158. 159. 160. 161. 162. 163. 164. 165. 166. 167. 168. 169. 170. 171. 172. 173. 174. 175. 176. 177. 178. 179. 180. 181. 182. 183. 184. версию JVM можно посмотреть, например - readme при создании базы $ORACLE_HOME/javavm/doc/readme.txt - либо Код: plsql 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. exp/imp java source перенесет точно, если они были созданы в ваших схемах, останется проверить status, права и работу то что грузили loadjava (object_type='JAVA CLASS', удалите dropjava и залейте классы новой версии сверьте до и после Код: plsql 1. ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 20.02.2015, 15:12:04 |
|
||
|
Oracle 11 Mail API
|
|||
|---|---|---|---|
|
#18+
Я нашел,как это лечится. Не понимаю, почему именно это, нашел на каком то немецком сайте, по теме с этим не связанной, но факт - помогает. После строчек // Set the Date: header msg.setSentDate(new Date()); нужно добавить msg.saveChanges(); После этого мы начали получать другой стек ошибок, и вот это уже лечится путем loadjava –r –v –f -u a/a@a mail-1.4.jar mail-1.4.jar мы download с OTN. видимо, в нашей версии Oracle Database 11g Release 11.2.0.4.0 неправильный mail.jar ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 05.09.2016, 11:28:55 |
|
||
|
|

start [/forum/topic.php?fid=52&fpage=203&tid=1887536]: |
0ms |
get settings: |
6ms |
get forum list: |
11ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
54ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
26ms |
get tp. blocked users: |
1ms |
| others: | 196ms |
| total: | 310ms |

| 0 / 0 |
