8 Replies Latest reply: Mar 23, 2010 2:29 PM by Hoek RSS

    how to send a mail using utl_mail

    749959
      Dear Experts

      i am facing problem while using the utl_mail package. whatever steps i have follow is underwritten.
      have a look.......

      SQL> ALTER SYSTEM SET SMTP_OUT_SERVER='smtp.gmail.com' SCOPE=SPFILE;

      System altered.

      SQL> @?/rdbms/admin/utlmail.sql

      Package created.


      Synonym created.

      SQL> @?/rdbms/admin/prvtmail.plb

      Package body created.

      No errors.
      SQL> BEGIN
      2 UTL_MAIL.SEND(SENDER => 'sudhir.kumar@sqlstar.com',recipients => 'dharmendra_s001@hotmail.com',message => 'all is well', subject =>'wishes 4 u');
      3 END;
      4 /
      BEGIN
      *
      ERROR at line 1:
      ORA-29279: SMTP permanent error: 530 5.7.0 Must issue a STARTTLS command first.
      39sm1824546yxd.6
      ORA-06512: at "SYS.UTL_SMTP", line 21
      ORA-06512: at "SYS.UTL_SMTP", line 99
      ORA-06512: at "SYS.UTL_SMTP", line 222
      ORA-06512: at "SYS.UTL_MAIL", line 407
      ORA-06512: at "SYS.UTL_MAIL", line 594
      ORA-06512: at line 2

      please do needful..

      thanks in advance.

      regards
      dharmendra
        • 1. Re: how to send a mail using utl_mail
          Prazy
          Hi,

          I doubt you can use Gmail server as a smtp server. you should have your own SMTP server to trigger a mail.

          And, Follow the below links for further details

          http://www.psoug.org/reference/utl_smtp.html
          http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_smtp.htm#ARPLS074


          Regards,
          Prazy
          • 2. Re: how to send a mail using utl_mail
            Billy~Verreynne
            You're attempting to use another company's mail server to deliver mail for you - it expects authentication/encryption. You're not supplying it via UTL_MAIL.

            See http://en.wikipedia.org/wiki/STARTTLS for details.
            • 3. Re: how to send a mail using utl_mail
              Tubby
              I don't suspect GMAIL will allow you to flood their SMTP server with requests.

              You can find working demos at Morgan's Library ... once you get your own SMTP server up and running.

              http://www.psoug.org/reference/utl_mail.html
              • 4. Re: how to send a mail using utl_mail
                749959
                ur given hint is not working kindly provide me solution for personal pc.
                • 5. Re: how to send a mail using utl_mail
                  Hoek
                  Who is your internet provider? You can try the name of the smtp server of your provider.
                  Besides gmail/yahoo/hotmail etc., if you also have a working Outlook (Express) account from your own provider, check your account properties and use that smtp server.

                  SQL> ALTER SYSTEM SET SMTP_OUT_SERVER='your_provider's_smtp_server' SCOPE=SPFILE;

                  (At least: that approach worked fine for me...)
                  • 6. Re: how to send a mail using utl_mail
                    749959
                    I don't use outlook express.

                    I do use hotmail; gmail kind of mailing account.

                    so please provide me solution, accordingly.
                    • 7. Re: how to send a mail using utl_mail
                      TheOtherGuy
                      GMAIL uses encrypted authentication, I would use SMTP relay (there are tons of free relays out there), here are few samples how to set it up with gmail (what OS you plan to run it on?)

                      http://emailrelay.sourceforge.net - I was using this with gmail, it works great


                      here is how to use it with gmail http://emailrelay.sourceforge.net./userguide.html#SH_1_5



                      after you install it, point your Oracle to your internal SMTP relay server IP address, relay is super tiny app and really won't each much resources
                      • 8. Re: how to send a mail using utl_mail
                        Hoek
                        But, you apparently do have an internet account (usually nowadays internet and email etc. is 'all included'), else you wouldn't be posting here. So, let's assume your provider is ACME and you live in Holland (= .nl), then you could try:

                        ALTER SYSTEM SET smtp_out_server='smtp.acme.nl' SCOPE=SPFILE;

                        You need to figure that out yourself, since we don't know who provides you internet access (nor whether it would work).
                        That would be the simplest way.
                        Not sure whether you can get gmail etc. to 'work with you': Re: utl.mail - smtp_out_server parameter