How to send email using Oracle Stored Procedure - oracle11g

I am creating auto risk assessment.
if the risk found the email will be send to concern director. and this work all the time even in week off.
i have created the procedure for calculating the risk and it is working. but how to let it send email to specific email automatically for example. xxx#gmail.com. I found one producer but it shows and error:
Network access denied by access control list (ACL)
here is the procedure:
create or replace PROCEDURE SEND_MAIL (
msg_to varchar2 ,
msg_subject varchar2 ,
msg_text varchar2 )
IS
c utl_smtp.connection;
rc integer;
msg_from varchar2(50) := 'smsnotfication#gmail.com';
mailhost VARCHAR2(30) := '192.168.10.13'; -- technova local database host
BEGIN
c := utl_smtp.open_connection(mailhost,465); -- SMTP on port 25
utl_smtp.helo(c, mailhost);
utl_smtp.mail(c, msg_from);
utl_smtp.rcpt(c, msg_to);
utl_smtp.data(c,'From: Oracle Database' || utl_tcp.crlf ||
'To: ' || msg_to || utl_tcp.crlf ||
'Subject: ' || msg_subject ||
utl_tcp.crlf || msg_text);
utl_smtp.quit(c);
EXCEPTION
WHEN UTL_SMTP.INVALID_OPERATION THEN
dbms_output.put_line(' Invalid Operation in Mail attempt
using UTL_SMTP.');
WHEN UTL_SMTP.TRANSIENT_ERROR THEN
dbms_output.put_line(' Temporary e-mail issue - try again');
WHEN UTL_SMTP.PERMANENT_ERROR THEN
dbms_output.put_line(' Permanent Error Encountered.');
END;

It seems that you didn't create ACL, did you? If not, here's an excerpt from my script - have a look.
Pay attention to HOST while assigning ACL - this might need to be the IP address you mentioned.
I never tried to do what you're doing, but - hopefully - it'll help.
SELECT * FROM dba_network_acls;
-- Drop ACL ====================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.drop_acl (acl => 'myacl.xml');
END;
-- Create ACL ==================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.create_acl (acl => 'myacl.xml',
description => 'SMTP, MAIL, HTTP Access',
principal => 'SCOTT',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL);
END;
-- Assign ACL ==================================================================
BEGIN
DBMS_NETWORK_ACL_ADMIN.assign_acl (acl => 'myacl.xml',
HOST => '*', --> 192.168.10.13 ?
lower_port => NULL,
upper_port => NULL);
END;
-- Add privilege ===============================================================
BEGIN
-- SCOTT
DBMS_NETWORK_ACL_ADMIN.add_privilege (acl => 'myacl.xml',
principal => 'SCOTT',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL);
DBMS_NETWORK_ACL_ADMIN.add_privilege (acl => 'myacl.xml',
principal => 'SCOTT',
is_grant => TRUE,
privilege => 'resolve',
start_date => NULL,
end_date => NULL);
END;
/
COMMIT;

Related

Ora 06502 for apex_web_service.g_request_headers bearer token PLSQL

I have a hard time to make a GET request form a server with Bearer token. To make a request I made a function which is down below and I'm getting error Ora-06512 in the line with bearer. Sending a request from postman is not a problem I recive my json response back. However with PLSQL I'm still not able to do that.
My function
FUNCTION get_response(ulr_path in varchar2)
RETURN clob
IS
z clob;
V_PARAM_NAMES apex_application_global.vc_arr2;
V_PARAM_VALUES apex_application_global.vc_arr2;
begin
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).VALUE := 'application/json';
apex_web_service.g_request_headers(2).name := 'Authorization';
apex_web_service.g_request_headers(2).value := 'Bearer ' || TOKEN; --ORA 06512
--apex_web_service.g_request_headers(2).name := 'Accept';
--apex_web_service.g_request_headers(2).VALUE := '*/*';
V_PARAM_NAMES(1) := 'fist_param_name';
V_PARAM_VALUES(1) := 'first_param_value';
V_PARAM_NAMES(2) := 'second_param_name';
V_PARAM_VALUES(2) := 'second_param_value';
z := APEX_WEB_SERVICE.make_rest_request(p_url => ulr_path,
p_http_method => 'GET',
p_proxy_override => null,
p_transfer_timeout => 60,
--p_password => HUMO_TOKEN,--
--p_body => HUMO_TOKEN,
p_body_blob => null,
p_parm_name => V_PARAM_NAMES,
p_parm_value => V_PARAM_VALUES
);
RETURN z;
END;
The postman curl (which is works perfectly fine) looks like this
curl --location --request GET 'http://huamoapay.mur.ru/api/servicea' \
--header 'Authorization: Bearer really_long_string'
The error img
apex_web_service.g_request_headers.delete();
apex_web_service.g_request_headers(1).name := 'Content-Type';
apex_web_service.g_request_headers(1).value := 'application/json';
apex_web_service.g_request_headers(2).name := 'Authorization';
apex_web_service.g_request_headers(2).value := 'Bearer ' || v_json_keyvalue;
l_clob :=
apex_web_service.make_rest_request(p_url => ulr_path,
p_http_method => 'GET',
p_transfer_timeout => 180,
p_body => null);
v_json_obj := json_object_t.parse(l_clob);
z := v_json_obj.get_string('id');
return z;
Use this format and then try

Multisite - New User Registration Failing

I have a Wordpress site using multisite set up and everything works as expected bar new user registration.
When I add a new user, the email gets sent as expected but then when you click on the activation link I get the following message:
An error occurred during the activation
Invalid activation key.
When I look in the wp_users table I can't see those particular users who have been sent the email as obviously the link hasn't worked.
If I set up a user and choose not to send the email then they are all showing with an 'ID' of 0 in the wp_user table.
This all worked pre-migration to a new server so I am not sure where to begin in terms of tracking down the problem.
All help is greatly appreciated.
I get the following two errors in the debug log:
[17-Dec-2019 12:57:38 UTC] WordPress database error Duplicate entry '0' for key 'PRIMARY' for query INSERT INTO `wp_5_posts` (`post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_content_filtered`, `post_title`, `post_excerpt`, `post_status`, `post_type`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_parent`, `menu_order`, `post_mime_type`, `guid`) VALUES (1, '2019-12-17 12:57:38', '0000-00-00 00:00:00', '', '', 'Auto Draft', '', 'auto-draft', 'post', 'open', 'open', '', '', '', '', '2019-12-17 12:57:38', '0000-00-00 00:00:00', 0, 0, '', '') made by wp_dashboard, do_meta_boxes, wp_dashboard_quick_press, get_default_post_to_edit, wp_insert_post
[17-Dec-2019 12:58:30 UTC] WordPress database error Duplicate entry '0' for key 'PRIMARY' for query INSERT INTO `wp_signups` (`domain`, `path`, `title`, `user_login`, `user_email`, `registered`, `activation_key`, `meta`) VALUES ('', '', '', '<username>', '<email address>', '2019-12-17 12:58:30', '75429b53ffc95fcd', 'a:2:{s:11:\"add_to_blog\";i:5;s:8:\"new_role\";s:10:\"subscriber\";}') made by wpmu_signup_user

COMMERCE ORDER - PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction

Here is my error message
PDOException: SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when
trying to get lock; try restarting transaction:
UPDATE {commerce_order} SET
order_number=:db_update_placeholder_0, revision_id=:db_update_placeholder_1,
type=:db_update_placeholder_2, uid=:db_update_placeholder_3,
mail=:db_update_placeholder_4, status=:db_update_placeholder_5,
created=:db_update_placeholder_6, changed=:db_update_placeholder_7,
placed=:db_update_placeholder_8, hostname=:db_update_placeholder_9,
data=:db_update_placeholder_10 WHERE (order_id = :db_condition_placeholder_0) ;
Array ( [:db_update_placeholder_0] => 201805822 [:db_update_placeholder_1] => 16807
[:db_update_placeholder_2] => commerce_order [:db_update_placeholder_3] => 0
[:db_update_placeholder_4] => [:db_update_placeholder_5] => checkout_checkout
[:db_update_placeholder_6] => 1540480400 [:db_update_placeholder_7] =>
1540481979 [:db_update_placeholder_8] => 0 [:db_update_placeholder_9] =>
128.199.161.50 [:db_update_placeholder_10] => a:4:
{s:17:"last_cart_refresh";i:1540481976;s:16:"shipping_service";s:17:"shipping_custom|1";s:14:"with_backorder";s:0:"";s:17:"backorder_service";s:5:"_none";}
[:db_condition_placeholder_0] => 5056 ) in drupal_write_record() (line 7387 of ~/public_html/includes/common.inc).
anyone can help me? whats wrong with that things?
The best fix is changing your transaction isolation level (to READ COMMITTED).
Try adding this to your settings.php. It's a common problem in high read/write Drupal sites with many fields.
$databases['default']['default']['init_commands'] = array(
'isolation' => "SET SESSION tx_isolation='READ-COMMITTED'"
);

Silex: Set firewalls session lifetime

I'm trying to extend the default lifetime once a user logs in. For the login I'm using the security service provider as follows:
$app = $this->_app;
$this->_app->register(new Silex\Provider\SecurityServiceProvider(), array(
'security.firewalls' => array(
'default' => array(
'pattern' => '^.*$',
'anonymous' => true, // Needed as the login path is under the secured area
'form' => array('login_path' => '/signup/', 'check_path' => 'login_check', 'failure_path' => 'login_failure'),
'logout' => array('logout_path' => '/logout/'), // url to call for logging out
'users' => $this->_app->share(function() use ($app)
{
// Specific class App\User\UserProvider is described below
return new UserProvider($app['db']);
}),
),
),
'security.access_rules' => array(
array('^/restricted/$', 'ROLE_USER'),
)
));
I've tried setting up with the sessions lifetime (cookie) like this:
$this->_app->register(new Silex\Provider\SessionServiceProvider(), array(
'session.storage.options' => array('cookie_lifetime' => (60 * 60 * 12)), // 12 hours
));
But still nothing. Session removes itself after like 15 minutes or so.
How can I extend the login security firewall lifetime to 12 hours?
I think I finally got it working:
Saving sessions in database seemed to solve the problem.
SQL:
CREATE TABLE `session` (
`session_id` varchar(255) NOT NULL,
`session_value` text NOT NULL,
`session_time` int(11) NOT NULL,
PRIMARY KEY (`session_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
PHP:
/* SESSION IN DB */
$this->_app->register(new Silex\Provider\SessionServiceProvider());
$this->_app['session.db_options'] = array(
'db_table' => 'session',
'db_id_col' => 'session_id',
'db_data_col' => 'session_value',
'db_time_col' => 'session_time',
);
$this->_app['session.storage.handler'] = $this->_app->share(function ()
{
return new PdoSessionHandler(
$this->_app['db']->getWrappedConnection(), $this->_app['session.db_options'], $this->_app['session.storage.options']
);
});
Here is a solution if you don't want to store sessions in DB: just increase session.gc_maxlifetime in php.ini.
When sessions are being stored in files, they (by default) get put to /var/lib/php/sessions/ directory. It's clear that this directory has to be cleared from time to time. In order to achieve this, there is a cron job configured at /etc/cron.d/php5 that fires script /usr/lib/php5/sessionclean every 30 minutes. This script takes php config and gets session.gc_maxlifetime from there and then removes files that are older than what is specified in this variable.
The problem is: by default session.gc_maxlifetime equals to 1440 seconds or 24 minutes. You can increase it to whatever value suits you, for instance to 24 hours (and limit your sessions by session cookie lifetime).

Drupal Menu Throws SQL Error

I have this weird problem with Drupal Menus. When I try to add a link to any drupal menu, it throws the following SQL exception. I can create a new menu or delete an existing one, but I can't add any links :-) Any help?
Additional uncaught exception thrown while handling exception.
Original
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'; Array ( [:language] => tr [:source] => Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters. [:context] => ) in locale() (line 684 of /home/predra/public_html/modules/locale/locale.module).
Additional
PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => php [:db_insert_placeholder_2] => %type: !message in %function (line %line of %file). [:db_insert_placeholder_3] => a:6:{s:5:"%type";s:12:"PDOException";s:8:"!message";s:495:"SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT s.lid, t.translation, s.version FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = :language WHERE s.source = :source AND s.context = :context AND s.textgroup = 'default'; Array ( [:language] => tr [:source] => Configure how content input by users is filtered, including allowed HTML tags. Also allows enabling of module-provided filters. [:context] => ) ";s:9:"%function";s:8:"locale()";s:5:"%file";s:53:"/home/predra/public_html/modules/locale/locale.module";s:5:"%line";i:684;s:14:"severity_level";i:3;} [:db_insert_placeholder_4] => 3 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => http://predra.com/admin/structure/menu/manage/menu-header-menu/add [:db_insert_placeholder_7] => http://predra.com/doktor/haldun-san [:db_insert_placeholder_8] => 78.180.179.155 [:db_insert_placeholder_9] => 1348828684 ) in dblog_watchdog() (line 154 of /home/predra/public_html/modules/dblog/dblog.module).
Please change max_allowed_packet to 20M or more in mysql\bin\my.ini (depends on your mysql server config path.)
It works!

Resources