ã¯ããã«
ãã®çãèšäºã§ã¯ãOracleããã®ã¡ãŒã«éä¿¡ã®èšå®æ¹æ³ãšçµäºæ¹æ³ã«ã€ããŠèª¬æããŸãã ããã«2ã€ã®ããšãæ確ã«ããããšæããŸãã1ã€ç®ã¯ãã¹ããã³ã°ã®ããã«ãããããªãã£ãããšã§ãã2ã€ç®ã¯ãã¡ãŒã«ãµãŒããŒã®ã»ããã¢ããã«åãçµãã§ããŸããã§ããã
Oracleã»ããã¢ãã
ç§ã®ã¿ã¹ã¯ã®1ã€ã解決ããããã«ããŠãŒã¶ãŒèªèšŒããŒã¿ãéä¿¡ããå¿ èŠã«çŽé¢ããŸããã ããŒãã«ã«ãããã°ã€ã³ãšãã¹ã¯ãŒãã ççŽã«èšã£ãŠãçŸæç¹ã§ã¯æ°çŸäººãæ°å人ã®ãŠãŒã¶ãŒãããªãã®ã§ã誰ããæã§æçŽãéãããšãã§ããŸãããããã¯æ°æéã®æäœæ¥ã§ãã
äœæ¥ã®æåŸã®å Žæã§ã¯ãæ¯æã¬ããŒãããŠãŒã¶ãŒã«ã¡ãŒã«ã§éä¿¡ããå¿ èŠããã£ããããã¿ã¹ã¯ã¯ç§ã«ãšã£ãŠãšããŸããã¯ã«èŠããŸããã§ããããŸããæäœæ¥ã«èŠåã£ãæéãåŠçã§ãããšæåŸ ããŠããŸããã äžæ¹ãå¿ èŠãªã€ã³ãã©ã¹ãã©ã¯ãã£ã¯ãã¹ãŠæå ã«ãããå¿ èŠãªãããã¯ã®å°é家ãããŠã圌ããšè©±ãããšãã§ããŸããã ããã«ã¯äœããããŸããã§ãã-èªåã§ç解ããå¿ èŠããããŸãã
Oracleã«ã¯ãããŒã¿ããŒã¹ããã¡ãŒã«ãéä¿¡ããããã®å€ãã®æ¹æ³ããããŸããå¿ èŠãªæ©èœãåããããã±ãŒãžã®äžéšã次ã«ç€ºããŸãã
- UTL_MAIL
- UTL_SMTP
- UTL_TCP
- UTL_HTTP
1.ããã±ãŒãžä»æ§ã¯ããã¡ã€ã«@ $ ORACLE_HOME \ rdbms \ admin \ utlmail.sqlã«ãããŸãã
2.ããã±ãŒãžæ¬äœã¯æå·åããããã¡ã€ã«@ $ ORACLE_HOME \ rdbms \ admin \ prvtmail.sqlã«ãããŸãã
ããã¯SYSãŠãŒã¶ãŒã®äžããããŒã«ã¢ãŠãããå¿ èŠãããã ã³ãã³ããŠã£ã³ããŠPL / SQL Developerããããã±ãŒãžãæ£åžžã«ã€ã³ã¹ããŒã«ã§ããŸããã§ãã ã€ã³ã¹ããŒã«ãããŸããããã³ã³ãã€ã«ãšã©ãŒãçæãããŸããã sqlplusãããã¹ãŠãå®å šã«ã€ã³ã¹ããŒã«ãããŸããã
ããŒã«ã¢ããåŸãããã±ãŒãžã䜿çšããããã®èš±å¯ãäžããå¿ èŠããããŸãã äžéšã®èè ã¯ã Publicã«èš±å¯ãäžããããšãææ¡ããŠããŸãããããã¯ã»ãã¥ãªãã£äžã®çç±ããè¯ãèãã§ã¯ãããŸããã é©åãªãŠãŒã¶ãŒã«èš±å¯ãäžããããåŸã SYSãŠãŒã¶ãŒã®äžã§ã®äœæ¥ã¯å®äºããŸããïŒãã ãã alter systemãå®è¡ããå¿ èŠãããç¶æ³ãäŸç¶ãšããŠå¿ èŠã§ã ïŒã
ã¡ãŒã«ãµãŒããŒ
çµå±ã®ãšãããã¡ãŒã«ãéä¿¡ããããã®ã€ã³ãã©ã¹ãã©ã¯ãã£ãã€ãŸã Oracleãé€ããŠãç§ãæã£ãŠããªãã¡ãŒã«ãµãŒããŒãå¿ èŠã§ããã€ã³ã¹ããŒã«ãšæ§æã®æ¹æ³ãæ³åã§ããŸããã§ãããå¿ èŠã§ããïŒ
çãæ€çŽ¢ã®åŸã次ã®èšäºhttp://jiri.wordpress.com/2010/03/24/send-emails-using-utl_mail-and-google-gmail-smtp-server/ãèŠã€ããŠãGMAILçµç±ã§ã¡ãŒã«ãéä¿¡ããæ¹æ³ã説æããŸããã èšäºã®èè ã¯ç§ã®ãããªç¶æ³ã«é¥ããç°¡åãªè§£æ±ºçãææ¡ããŸãããããã䜿çšããããšã«ããŸããã GMAILã§æ°ããã¡ãŒã«ããã¯ã¹ãéå§ããŸããããã®ã¡ãŒã«ããã¯ã¹ã¯ã E-MailRelayã®ããŠã³ããŒããšã€ã³ã¹ããŒã«ãèªåçã«è¡ãããã«äœ¿çšãããŸãã ããã«ããã¯ããŸããããŸããã§ãããããã¥ã¡ã³ããå°ãèªãã§ããã®ãµãŒããŒãšã®çžäºäœçšã説æããèšäºããã£ãšæ¢ãå¿ èŠããããŸããã ãã®çµæãå¿ èŠãªãã¹ãŠã®ãã©ã¡ãŒã¿ãŒãbatãã¡ã€ã«ã«å ¥åãããã¡ãŒã«ããã¯ã¹ããŒã¿ãemailrelay.authãã¡ã€ã«ã«å ¥åããããµãŒããŒãæ£åžžã«èµ·åããŸããã
æçŽãéã
ã¡ãŒã«ãµãŒããŒïŒãŸãã¯ãã®å Žåã®ããã«SMTPãããã·ïŒãã€ã³ã¹ããŒã«ããåŸãOracleã®ã¢ãã¬ã¹ãæå®ããå¿ èŠããããŸãã
alter system set smtp_out_server = 'ip-address:port' scope=Both;
ç§ã®å ŽåãOracleãšSMTPãããã·ã¯åããã·ã³äžã«ããããã ã¢ãã¬ã¹ã¯127.0.0.1ãããŒã25ã§ãã
utl_mail.sendã䜿çšããŠã¡ãŒã«ãéä¿¡ããŠã¿ãŸãããããã®ãããèšå®ã§å°ãéã¶å¿ èŠããããŸãããããšãã°ãéä¿¡è ãã£ãŒã«ãã«ã¯æ¬¡ã®åœ¢åŒã®ã¢ãã¬ã¹ãå¿ èŠã§ããããšãããããŸããã
"<any_mail@any_mail_server.com>" ãåãå Žæã§éä¿¡è ã®ååãæå®ããããšãã§ããŸãã
ãéä¿¡è å<my_mail@any_mail_server.com>ãã§ãããã¡ãã»ãŒãžã¯å®éã®Gmailã¡ãŒã«ããã¯ã¹ãããšã«ããå±ã ã次ã®ããã«ãªããŸãã
ãéä¿¡è å<my_mail@any_mail_server.com>ã<real_mailbox@gmail.com>
mime_typeã䜿çšããŠããŸããŸãªã¡ãŒã«ãµãŒããŒã«éä¿¡ããå°ãã®å®éšã«ããããã·ã¢èªã®ããã¹ãã«ã¯'text / htmlã䜿çšããããšãæãŸããããšã瀺ãããŸããã charset = "UTF-8" '
ã³ã³ãããŒã«ãèªåã«æçŽãéä¿¡ããåŸãå¿ èŠãªããŒã¿ãéžæããåãŠãŒã¶ãŒã«ãŠãŒã¶ãŒå/ãã¹ã¯ãŒããéä¿¡ããæé ãäœæãããŸããã æåã®20人ã®ãŠãŒã¶ãŒã«ããŒã¿ãéä¿¡ããããã®ãã®æé ãéå§ããããæŒé£ã«åºãããŸããã
çŽ40ååŸãæåã®4æåã ããæ¶ããæ®ãã¯ã©ããã«çãŸã£ãŠããããšãããããŸããã ãããã°ã®æºåãšããŠãåãæé ã䜿çšããŠã¡ãŒã«ããã¯ã¹ã«10æåãéä¿¡ããŸããã æ°ããããã±ãŒãžã¯å€±ãããæçŽããæŒãéããããããã¯ãã¹ãŠæ£åžžã«æŸçœ®ãããŸããã äžè¬ã«ãSMTPãããã·ã¯æ©èœããŸããããå€å°ã®ççŸã¯ãããŸããã
ç©èªã®ç¶ã
1æ¥åŸããµãŒããŒã§èªåã®ããžãã¹ãè¡ããšãSMTPãããã·ãçŽ80æåãéä¿¡ããŠããããšãããããŸããããæåã®ã¡ãŒã«éä¿¡åŸã¯äœãéä¿¡ããŸããã§ããã ç§ã¯gmail'eã®ããã¯ã¹ããã§ãã¯ããããšã«ããŸããã åä¿¡ãã¬ã€ã«ã¯ã3ã€ã®ã¬ã¿ãŒããã¯ããããŸããã
3ã€ã®ãã§ãŒã³ãã¹ãŠã«ãååšããªãã¡ãŒã«ããã¯ã¹ãžã®ã¡ãã»ãŒãžéä¿¡ã«é¢ããã¡ãŒã«ãµãŒããŒã®å¿çãå«ãŸããŠããŸããã 次ã®åçãéä¿¡ãããã¡ãã»ãŒãžã§èŠ³å¯ãããŸããã
ã¡ãŒã«ããã¯ã¹ããvbibiorm@gmail.comãšw852@ymail.comã®ã¡ãŒã«ããã¯ã¹ã«2ã€ã®æåãæ®ã£ãŠããã件åã®åæåã«ã¯ãSMTPãããã·ãã€ã³ã¹ããŒã«ãããŠãããã·ã³ã®IPã¢ãã¬ã¹ãå«ãŸããæåã®æ¬æã¯ç©ºã§ããããååãnonameã§ãµã€ãºã0ãã€ãã®æ·»ä»ãã¡ã€ã«ã1ã€ãããŸããã
æããã«ãSMTPãããã·ã«ã¯è匱æ§ããããæ·»ä»ãã¡ã€ã«ä»ãã®ã¡ãŒã«ãéä¿¡ãããšãã«ã®ã¿è¡šç€ºãããã®ããæ·»ä»ãã¡ã€ã«ã«ãã·ã³ã®è匱æ§/ç¹æ§ã«é¢ããè¿œå æ å ±ãå«ããå¿ èŠãããã®ãââããããŸããã äž¡æ¹ã®ã¡ãŒã«ããã¯ã¹ã«ã¡ãã»ãŒãžãéä¿¡ããæéã¯åãã§ããããããããã¯åã人ç©ã«å±ããŠãããšçµè«ä»ããŸãã çºèŠãããè匱æ§ã®çµæã次ã®ã¿ã€ãã®æåãSMTPãããã·ãä»ããŠéä¿¡ãããŸããã
Google翻蚳ã§ã¯ãæåã®èšèªãäžåœèªãšå®çŸ©ããŠããŸãã ãããã®é»åã¡ãŒã«ã«é¢ããæ å ±ãGoogleãæ€çŽ¢ãããšããããããã®ã¡ãŒã«ããã¯ã¹ãžã®æçŽã®éä¿¡ã«é¢é£ããã¡ãŒã«ãµãŒããŒã®äžå¯è§£ãªã¢ã¯ãã£ããã£ã«ã€ããŠãŠãŒã¶ãŒãäžæºãèšãããšããããããŸãã ã äžè¬ã«ãããã¯ç§ã®èŸæžã«ããªãŒãã³ãªã¬ãŒããšãããã¬ãŒãºãçŸããæ¹æ³ã§ãã SMTPãããã·ããªãã«ããŸãããã質åã¯æ®ããŸãã次ã«äœãããã°ããã§ããïŒ ç§ã¯3ã€ã®ãªãã·ã§ã³ãèŠãŸããïŒ
- ã¡ãŒã«ãé »ç¹ã«ããã±ãŒãžå šäœã§éä¿¡ããããšã¯èšç»ãããŠããªãã£ãããããã¹ãŠããã®ãŸãŸã«ããŠããããšãã§ããŸãã æçŽã®éä¿¡æã«ã®ã¿ã¡ãŒã«ãããã·ãæå¹ã«ããŸã-æéå ã§æãå®äŸ¡ãªãœãªã¥ãŒã·ã§ã³ã§ãã
- ã¡ãŒã«ãµãŒããŒã®ãããã¯ãå®å šã«ç解ãããããæ£ããæ§æããããããä¿¡é Œæ§ã®é«ããã®ã«å€æŽããããšãã§ããŸã-æéå ã«ããªãé«äŸ¡ãªãªãã·ã§ã³ã§ãããããã«ããã®ç¥èã¯å°æ¥ç§ã«ãšã£ãŠãŸã£ãã圹ã«ç«ã¡ãŸããã
- æ¢åã®ç¥èã䜿çšããŠåé¿çãèŠã€ããã«ã¯ãæéã®ã³ã¹ãã¯äžæã§ãã
- ã¡ãŒã«ãµãŒããŒã«ç²ŸéããŠããå人ãèŠã€ããŸãã
ãªãã·ã§ã³
æãç°¡åã§çæ³çãªãªãã·ã§ã³ã¯ããµãŒããŒãè¿œå ããã«ãGmailçµç±ã§ããã«ã¡ãŒã«ãéä¿¡ããããšã§ãã è©ŠããŠã¿ãŸãããïŒ
alter system set smtp_out_server = 'smtp.gmail.com:587' scope=Both;
ã¡ãã»ãŒãžãéä¿¡ããããšãããšã次ã®ãšã©ãŒãè¿ãããŸãããORA-29279ïŒSMTPããŒããã³ããšã©ãŒïŒ530 5.7.0æåã«STARTTLSã³ãã³ããçºè¡ããå¿
èŠããããŸãã m29sm5336584poh.20ãã ç§ã¯Gmailã®ããã¥ã¡ã³ãã«è¡ããä»ã®ããŒããè©Šããhttpsã§ã¯ãªãhttpãä»ããŠã¡ãŒã«ããã¯ã¹èšå®ã§äœæ¥ãèšå®ããããšããŸããã ãã®çµæããšã©ãŒã¡ãã»ãŒãžã¯å€ãããŸããããã¡ãŒã«ã¯æ¶ããŸããã§ããã ã€ã³ã¿ãŒãããã§ã®æ€çŽ¢ã§ã¯ãããã€ãã®ãã€ã³ãã瀺ãããŸããã - GmailãšYahooã§ã¯ãSTARTTLSïŒSSLã®å¥åïŒã䜿çšããå¿ èŠããããŸãã
- UTL_MAILã¯STARTTLSããµããŒãããŠããŸããã
- ç¹ã«é åºãªä»²éã¯utl_smtpããã±ãŒãžãšutl_smtp.commandïŒconnã 'STARTTLS'ïŒã³ãã³ãã䜿çšããããšããŸãããã倱æããŸããã ããã¥ã¡ã³ãã®ã©ããã«ãSTARTTLSãããŒãžã§ã³11.2ããOracleã«ãã£ãŠãµããŒããããŠããããšãããããŸããã
- ã³ãã¥ããã£ã®äžè¬çãªæèŠã¯æ¬¡ã®ãšããã§ãã
- GmailãYahooã䜿ãããèªåãã ãŸããªãã§ãã ããã
- Gmailã䜿çšããå Žåã¯ãSMTPãããã·ãèªåã§èšå®ããŸãïŒãªãã·ã§ã³ãèšäºã®åé ã§èª¬æããŸãïŒã
- äœãããŠããã®ãç解ã§ããããutl_smtpããã±ãŒãžã䜿çšããŠã¡ãŒã«ãµãŒããŒãžã®ãã°ã€ã³ãè©Šã¿ãããšãã§ããŸãã
ãããçµäºããæãæ¥ãããšãç解ããŠããŸãã次ã®æ€çŽ¢äžã«ãåçŽãªèããèŠã€ããŸããïŒç§ã®ããŒã25ã¯éããããŠããŸããïŒ ãã§ãã¯ããŸãïŒå€æããŸãããããã®æ¹æ³ãããããŸããïŒ-éããŸããã 代æ¿ã¡ãŒã«ãµãŒããŒãšããŒã587ã瀺ã代æ¿ã·ã¹ãã ãäœæããŸããUTL_MAILã䜿çšããŠé»åã¡ãŒã«ãéä¿¡ããããšãããšããORA-29279ïŒPermanent SMTPãšã©ãŒïŒ501 sender address must must be domainããšãããšã©ãŒã衚瀺ãããŸãã ããã¯ã»ãšãã©èµ·ãããŸãããéä¿¡è ã®ååã«å«ãŸããå¿ èŠãªGmail'y "<>"ãåãé€ããæçŽãæ®ããŸããã
ãããã«
ãã®èšäºã§ã¯ãçŸå Žã§ã¡ãŒã«ãéä¿¡ããçµéšãšãã¡ãŒã«ãµãŒããŒã®æäœã«é¢ããå¿ èŠãªç¥èããªãå Žåã«ã€ããŠèª¬æããŸããã 以åã«ã€ã³ã¹ããŒã«ããSMTPãããã·ãšåããæŒãããããã¡ãŒã«ãµãŒããŒãèŠã€ãã£ããããçµæã¯ããŸãæºè¶³ã®ãããã®ã§ã¯ãããŸããã ããã«1åãè²»ãããåŸãããšãã°æ¬¡ã®ããã«æå®ããã ãã§ãã¡ãŒã«ãµãŒããŒã«ååšããã¡ãŒã«ããã¯ã¹ã«ä»£ãã£ãŠã¡ãŒã«ãéä¿¡ã§ããããšãããããŸããã
ããã§ãmail ******ã¯ãèŠã€ãã£ãã¡ãŒã«ãµãŒããŒã®ååã§ãã ããããåé¡ã解決ããæŒãããããããã·ãšãã®èšå®ãç解ããå¿ èŠæ§ãåãé€ããUTL_MAILããã³UTL_SMTPãã±ããã«ã€ããŠããå°ãåŠã³ãŸããã ãªãã·ã§ã³4.cãæ±ãäºå®ã§ããããããŸããããŸããã§ãããæéããããªãããšã«ããŸããã誰ããGmailçµç±ã§OracleããçŽæ¥æçŽãéä¿¡ãçµããããããã«ã€ããŠèªãã®ã¯é¢çœãã§ãããã ïŒã¹ãã ãæ€åºããåŸïŒã¡ãŒã«ã®éä¿¡ãåæ§æãã䞊è¡ããŠèšäºãæžããšãã©ããã§6ã7æéããããŸãããv_sender varchar2(200):=' <admin@mail.******>'