The following code worked before I added the $_POSTs and populated the email variables manually but doesn't work now I've added them. Looking at the output, it appears that everything is OK, but I do not receive an the email (I've tried two different "To" addresses just incase it's an inbound server issue. Any thoughts?
`
`<?php
require("PHPMailer-master/src/PHPMailer.php");
require("PHPMailer-master/src/SMTP.php");
require_once 'PHPMailer-master/src/Exception.php';
if(isset($_POST['submit'])){
$name=$_POST['name'];
$email=$_POST['email'];
$phone=$_POST['phone'];
$date=$_POST['date'];
$p_name=$_POST['p_name'];
$dob=$_POST['dob'];
$gender=$_POST['gender'];
$height=$_POST['height'];
$weight=$_POST['weight'];
$oxygen=$_POST['oxygen'];
$message=$_POST['message'];
$mail = new PHPMailer\PHPMailer\PHPMailer();
$mail->IsSMTP(); // enable SMTP
$mail->SMTPDebug = 1; // debugging: 1 = errors and messages, 2 = messages only
$mail->SMTPAuth = true; // authentication enabled
$mail->SMTPSecure = 'ssl'; // secure transfer enabled REQUIRED for Gmail
$mail->Host = "smtp.xxxx.co.uk";
$mail->Port = 465; // or 587
$mail->IsHTML(true);
$mail->Username = "website#pxxxxxxxx.com";
$mail->Password = "xxxxxxxxxxxxxxxxxxx";
$mail->SetFrom($email, $name);
$mail->Subject = "Website Repatriation Form";
$mail->Body = "Contact Name: ".$name."\n"."Contact Phone No: ".$phone."\n"."Patient's Name: ".$p_name."\n"."Date of Birth: ".$dob."\n"."Gender: ".$gender."\n"."Height: ".$height."\n"."Needs Oxygen? :".$oxygen."\n"."Message:"."\n".$message;
$mail->AddAddress("xxxxxxxxxxxxxxxxx");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
}
?>`
`
With logging turned on, I get the following output:
2022-11-21 11:24:17 CLIENT -> SERVER: EHLO xxxxxxxx.com
2022-11-21 11:24:17 CLIENT -> SERVER: AUTH LOGIN
2022-11-21 11:24:17 CLIENT -> SERVER: [credentials hidden]
2022-11-21 11:24:17 CLIENT -> SERVER: [credentials hidden]
2022-11-21 11:24:17 CLIENT -> SERVER: MAIL FROM:<name#domain.com>
2022-11-21 11:24:17 CLIENT -> SERVER: RCPT TO:<name#domain.co.uk>
2022-11-21 11:24:17 CLIENT -> SERVER: DATA
2022-11-21 11:24:17 CLIENT -> SERVER: Date: Mon, 21 Nov 2022 12:24:17 +0100
2022-11-21 11:24:17 CLIENT -> SERVER: To: name#domain.co.uk
2022-11-21 11:24:17 CLIENT -> SERVER: From: Name <name#domain.com>
2022-11-21 11:24:17 CLIENT -> SERVER: Subject: Website Repatriation Form
2022-11-21 11:24:17 CLIENT -> SERVER: Message-ID: <WANZgAlHnYVPWwcMaFO7zyV8AXyiFTzo#domain.com>
2022-11-21 11:24:17 CLIENT -> SERVER: X-Mailer: PHPMailer 6.6.5 (https://github.com/PHPMailer/PHPMailer)
2022-11-21 11:24:17 CLIENT -> SERVER: MIME-Version: 1.0
2022-11-21 11:24:17 CLIENT -> SERVER: Content-Type: text/html; charset=iso-8859-1
2022-11-21 11:24:17 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit
2022-11-21 11:24:17 CLIENT -> SERVER:
2022-11-21 11:24:17 CLIENT -> SERVER: Contact Name: Webform name
2022-11-21 11:24:17 CLIENT -> SERVER: Contact Phone No: xxxxxxxxxxx
2022-11-21 11:24:17 CLIENT -> SERVER: Patient's Name: Eric Sprognasty
2022-11-21 11:24:17 CLIENT -> SERVER: Date of Birth: 1956-01-01
2022-11-21 11:24:17 CLIENT -> SERVER: Gender: Male
2022-11-21 11:24:17 CLIENT -> SERVER: Height: 5'11"
2022-11-21 11:24:17 CLIENT -> SERVER: Needs Oxygen? :No
2022-11-21 11:24:17 CLIENT -> SERVER: Message:
2022-11-21 11:24:17 CLIENT -> SERVER: Lorem ipsum dolor sit amet consectetur adipisicing elit. Dolorem aspernatur magnam sapiente dicta, harum quae iure, labore tenetur cumque odio nostrum nesciunt quos tempora maiores animi id et soluta vitae.
2022-11-21 11:24:17 CLIENT -> SERVER:
2022-11-21 11:24:17 CLIENT -> SERVER: .
2022-11-21 11:24:18 CLIENT -> SERVER: QUIT
Message has been sent
Running out of ideas. Ran the form with manually set email variables and it worked
i'm trying to start filebeat and send the output to ELK server, but getting the following error message when run command /usr/share/filebeat/bin/filebeat -e -c /etc/filebeat/filebeat.yml
error message:
2021-10-18T11:46:18.575Z ERROR [logstash] logstash/async.go:280 Failed to publish events caused by: write tcp 172.31.20.157:48724->MyPublicIP:5044: write: connection reset by peer
2021-10-18T11:46:18.575Z INFO [publisher] pipeline/retry.go:219 retryer: send unwait signal to consumer
2021-10-18T11:46:18.575Z INFO [publisher] pipeline/retry.go:223 done
2021-10-18T11:46:20.215Z ERROR [publisher_pipeline_output] pipeline/output.go:180 failed to publish events: write tcp 172.31.20.157:48724->MyPublicIP:5044: write: connection reset by peer
2021-10-18T11:46:20.215Z INFO [publisher_pipeline_output] pipeline/output.go:143 Connecting to backoff(async(tcp://MyPublicIP:5044))
2021-10-18T11:46:20.215Z INFO [publisher] pipeline/retry.go:219 retryer: send unwait signal to consumer
2021-10-18T11:46:20.215Z INFO [publisher] pipeline/retry.go:223 done
2021-10-18T11:46:20.216Z INFO [publisher_pipeline_output] pipeline/output.go:151 Connection to backoff(async(tcp://MyPublicIP:5044)) established
2021-10-18T11:46:20.273Z ERROR [logstash] logstash/async.go:280 Failed to publish events caused by: write tcp 172.31.20.157:48726->MyPublicIP:5044: write: connection reset by peer
here is the filbeat.yml config
# ------------------------------ Logstash Output -------------------------------
output.logstash:
# The Logstash hosts
hosts: ["MyPublicIP:5044"]
and here is the logstash-sample.conf in the ELK server
input {
beats {
port => 5044
type => "logs"
ssl => true
ssl_certificate => "/etc/pki/tls/certs/logstash-forwarder.crt"
ssl_key => "/etc/pki/tls/private/logstash-forwarder.key"
}
file {
path => "/var/log/*.log"
type => "syslog"
}
file {
path => "/tmp/logstash.txt"
}
}
output {
elasticsearch {
hosts => ["MyPublicIP:9200"]
index => "%{[#metadata][beat]}-%{[#metadata][version]}-%{+YYYY.MM.dd}"
#user => "elastic"
#password => "changeme"
}
}
i'm able to telnet the logstash from filbeat client server
[root#ip-172-x-x-x-system]# telnet MyPublicIP 5044
Trying MyPublicIP ...
Connected to MyPublicIP .
Escape character is '^]'.
Spring boot
retrofit 2
docker
in my docker-compose file:
version: "3"
services:
server:
image: asubscriber/eshop:1.0.1
build: .
ports:
- 8090:8090
Run my app (Spring boot) from console like this:
java -jar build/libs/eshop-1.0.1.jar eshop-1.0.1.jar
Run success. And success to http request. Here log:
[INFO ] 2020-03-14 21:41:09.480 [OkHttp http://localhost:8091/...] OkHttpClient - --> POST http://localhost:8091/api/v1/notifyEmail?emailTo=a_subscriber%40mail.ru&action=order_update&orderId=38 http/1.1
[INFO ] 2020-03-14 21:41:09.480 [OkHttp http://localhost:8091/...] OkHttpClient - Content-Length: 0
[INFO ] 2020-03-14 21:41:09.480 [OkHttp http://localhost:8091/...] OkHttpClient -
[INFO ] 2020-03-14 21:41:09.481 [OkHttp http://localhost:8091/...] OkHttpClient -
[INFO ] 2020-03-14 21:41:09.481 [OkHttp http://localhost:8091/...] OkHttpClient - --> END POST (0-byte body)
[INFO ] 2020-03-14 21:41:12.732 [OkHttp http://localhost:8091/...] OkHttpClient - <-- 200 http://localhost:8091/api/v1/notifyEmail?emailTo=a_subscriber%40mail.ru&action=order_update&orderId=38 (3250ms)
[INFO ] 2020-03-14 21:41:12.732 [OkHttp http://localhost:8091/...] OkHttpClient - Content-Type: application/json
[INFO ] 2020-03-14 21:41:12.732 [OkHttp http://localhost:8091/...] OkHttpClient - Transfer-Encoding: chunked
[INFO ] 2020-03-14 21:41:12.732 [OkHttp http://localhost:8091/...] OkHttpClient - Date: Sat, 14 Mar 2020 19:41:12 GMT
[INFO ] 2020-03-14 21:41:12.733 [OkHttp http://localhost:8091/...] OkHttpClient - Keep-Alive: timeout=60
[INFO ] 2020-03-14 21:41:12.733 [OkHttp http://localhost:8091/...] OkHttpClient - Connection: keep-alive
[INFO ] 2020-03-14 21:41:12.734 [OkHttp http://localhost:8091/...] OkHttpClient -
[INFO ] 2020-03-14 21:41:12.734 [OkHttp http://localhost:8091/...] OkHttpClient - {"code":0,"message":"Success"}
Nice. It's work fine. Success send POST http request.
Now I run SAME MY app by docker compose
docker-compose up
Success run app.
But if I want to create http request I get error:
Failed to connect to localhost/127.0.0.1:8091
server_1 | [INFO ] 2020-03-14 19:37:29.526 [OkHttp http://localhost:8091/...] OkHttpClient - --> POST http://localhost:8091/api/v1/notifyEmail?emailTo=a_subscriber%40mail.ru&action=order_update&orderId=4 http/1.1
server_1 | [INFO ] 2020-03-14 19:37:29.527 [OkHttp http://localhost:8091/...] OkHttpClient - Content-Length: 0
server_1 | [INFO ] 2020-03-14 19:37:29.527 [OkHttp http://localhost:8091/...] OkHttpClient -
server_1 | [INFO ] 2020-03-14 19:37:29.527 [OkHttp http://localhost:8091/...] OkHttpClient -
server_1 | [INFO ] 2020-03-14 19:37:29.527 [OkHttp http://localhost:8091/...] OkHttpClient - --> END POST (0-byte body)
server_1 | [DEBUG] 2020-03-14 19:37:29.529 [http-nio-8090-exec-5] SQL - select user0_.id as id1_3_, user0_.active as active2_3_, user0_.created as created3_3_, user0_.password as password4_3_, user0_.updated as updated5_3_, user0_.username as username6_3_ from usr user0_ where user0_.username=?
server_1 | [DEBUG] 2020-03-14 19:37:29.530 [http-nio-8090-exec-5] SQL - select roles0_.user_id as user_id1_2_0_, roles0_.role as role2_2_0_ from user_roles roles0_ where roles0_.user_id=?
server_1 | [DEBUG] 2020-03-14 19:37:29.530 [http-nio-8090-exec-5] SQL - select orders0_.user_id as user_id7_1_0_, orders0_.id as id1_1_0_, orders0_.id as id1_1_1_, orders0_.category_id as category6_1_1_, orders0_.created as created2_1_1_, orders0_.description as descript3_1_1_, orders0_.name as name4_1_1_, orders0_.updated as updated5_1_1_, orders0_.user_id as user_id7_1_1_ from orders orders0_ where orders0_.user_id=?
server_1 | [DEBUG] 2020-03-14 19:37:29.531 [http-nio-8090-exec-5] SQL - select orders0_.id as id1_1_, orders0_.category_id as category6_1_, orders0_.created as created2_1_, orders0_.description as descript3_1_, orders0_.name as name4_1_, orders0_.updated as updated5_1_, orders0_.user_id as user_id7_1_ from orders orders0_ where orders0_.user_id=?
server_1 | [DEBUG] 2020-03-14 19:37:29.536 [http-nio-8090-exec-5] SQL - select category0_.id as id1_0_0_, category0_.created as created2_0_0_, category0_.description as descript3_0_0_, category0_.name as name4_0_0_, category0_.updated as updated5_0_0_, orders1_.id as id1_1_1_, orders1_.category_id as category6_1_1_, orders1_.created as created2_1_1_, orders1_.description as descript3_1_1_, orders1_.name as name4_1_1_, orders1_.updated as updated5_1_1_, orders1_.user_id as user_id7_1_1_, user2_.id as id1_3_2_, user2_.active as active2_3_2_, user2_.created as created3_3_2_, user2_.password as password4_3_2_, user2_.updated as updated5_3_2_, user2_.username as username6_3_2_, roles3_.user_id as user_id1_2_3_, roles3_.role as role2_2_3_ from category category0_ left outer join orders orders1_ on category0_.id=orders1_.category_id left outer join usr user2_ on orders1_.user_id=user2_.id left outer join user_roles roles3_ on user2_.id=roles3_.user_id where category0_.id=?
server_1 | [INFO ] 2020-03-14 19:37:29.538 [OkHttp http://localhost:8091/...] OkHttpClient - <-- HTTP FAILED: java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8091
server_1 | [ERROR] 2020-03-14 19:37:29.539 [OkHttp http://localhost:8091/...] DefaultRestClientCallback - onFailure: Error: Failed to connect to localhost/127.0.0.1:8091
server_1 | java.net.ConnectException: Failed to connect to localhost/127.0.0.1:8091
server_1 | at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:265) ~[okhttp-3.14.4.jar!/:?]
server_1 | at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:183) ~[okhttp-3.14.4.jar!/:?]
server_1 | at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.java:224) ~[okhttp-3.14.4.jar!/:?]
server_1 | at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.java:108) ~[okhttp-3.14.4.jar!/:?]
Why same app not work from docker?
add this to your service in docker-compose file (only the network part)
version: "3"
services:
server:
image: asubscriber/eshop:1.0.1
build:
context: .
network_mode: "host"
expose:
- 9080
This is an answer to just make it works, it's better to read this, as Sergei Petunin mentiond in the comments above.
Hi I have a implemented oauth2 service in springboot. Auth-server and resource servers are enabled with eureka client they have successfully registered to eureka server as well. URI for auth-server in resource server is configured this way
security:
oauth2:
resource:
token-info-uri: http://auth-server/oauth/check_token
Now auth-server in the above URI is the app name of authserver. I am expecting resource server should contact auth server using token-info-uri after it gets url resolved from eureka server. But with this setup I am getting an error nested exception is java.net.UnknownHostException: auth-server
I modified my configuration to this
security:
oauth2:
resource:
prefer-token-info: false
service-id: auth-server
token-info-uri: http://${security.oauth2.resource.service-id}/oauth/check_token
loadBalanced: true
but I am getting response
{
"error": "invalid_token",
"error_description": "e2f95093-085c-4b59-90a5-c89fb5d1eccb"
}
When I debug I have this log
asset-mgmt-v1.1_1 | 2019-11-16 17:52:08.048 INFO 1 --- [nio-6001-exec-2] o.s.web.servlet.DispatcherServlet : Completed initialization in 21 ms
asset-mgmt-v1.1_1 | 2019-11-16 17:52:08.086 DEBUG 1 --- [nio-6001-exec-2] o.s.b.a.s.o.r.UserInfoTokenServices : Getting user info from: null
asset-mgmt-v1.1_1 | 2019-11-16 17:52:08.109 DEBUG 1 --- [nio-6001-exec-2] org.springframework.web.HttpLogging : HTTP GET
asset-mgmt-v1.1_1 | 2019-11-16 17:52:08.117 DEBUG 1 --- [nio-6001-exec-2] org.springframework.web.HttpLogging : Accept=[application/json, application/*+json]
asset-mgmt-v1.1_1 | 2019-11-16 17:52:08.119 WARN 1 --- [nio-6001-exec-2] o.s.b.a.s.o.r.UserInfoTokenServices : Could not fetch user details: class java.lang.IllegalStateException, Request URI does not contain a valid hostname:
asset-mgmt-v1.1_1 | 2019-11-16 17:52:08.120 DEBUG 1 --- [nio-6001-exec-2] o.s.b.a.s.o.r.UserInfoTokenServices : userinfo returned error: Could not fetch user details
asset-mgmt-v1.1_1 | 2019-11-16 17:52:08.127 DEBUG 1 --- [nio-6001-exec-2] o.s.b.a.audit.listener.AuditListener : AuditEvent [timestamp=2019-11-16T17:52:08.125Z, principal=access-token, type=AUTHENTICATION_FAILURE, data={type=org.springframework.security.authentication.BadCredentialsException, message=e2f95093-085c-4b59-90a5-c89fb5d1eccb}]
Basically URI is picked up is what I see
you cannot use just name in property files. it should be
security:
oauth2:
resource:
service-id: {Service ID as at eureka server registered}
token-info-uri: http://${security.oauth2.resource.service-id}/oauth/check_token
loadBalanced=true
prefer-token-info=false
P.S I just typed by hand. make sure keep proper spaces
In the error log presented by Darshu, there is the following message:" asset-mgmt-v1.1_1 | 2019-11-16 17:52:08.120 DEBUG 1 --- [nio-6001-exec-2] o.s.b.a.s.o.r.UserInfoTokenServices : userinfo returned error: Could not fetch user details".
The prefer-token-info must be set true to determine that token-info-uri is preferred over user-info-uri.
security:
oauth2:
resource:
prefer-token-info: true
See more in https://docs.spring.io/spring-security-oauth2-boot/docs/2.0.0.RC2/reference/htmlsingle/#boot-features-security-oauth2-resource-server
I have the following code refered from here in my middlewares.py which i'm trying to change my ip in TOR with every request
def _set_new_ip():
with Controller.from_port(port=9051) as controller:
controller.authenticate(password='tor_password')
controller.signal(Signal.NEWNYM)
class RandomUserAgentMiddleware(object):
def process_request(self, request, spider):
ua = random.choice(settings.get('USER_AGENT_LIST'))
if ua:
request.headers.setdefault('User-Agent', ua)
class ProxyMiddleware(object):
def process_request(self, request, spider):
_set_new_ip()
request.meta['proxy'] = 'http://127.0.0.1:8118'
spider.log('Proxy : %s' % request.meta['proxy'])
But when i try to start the crawling in scrapy it keeps returning me the following:
2017-09-10 22:36:44 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2017-09-10 22:36:44 [stem] DEBUG: GETCONF __owningcontrollerprocess (runtime: 0.0004)
2017-09-10 22:36:44 [stem] INFO: Error while receiving a control message (SocketClosed): empty socket content
2017-09-10 22:36:44 [IT] DEBUG: Proxy : http://127.0.0.1:8118
2017-09-10 22:36:44 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET https://www.jobstreet.com.sg/en/job-search/job-vacancy.php?ojs=10&key=information%20technology> (failed 1 times): Connection was refused by other side: 61: Connection refused.
2017-09-10 22:36:44 [stem] DEBUG: GETCONF __owningcontrollerprocess (runtime: 0.0003)
2017-09-10 22:36:44 [stem] INFO: Error while receiving a control message (SocketClosed): empty socket content
2017-09-10 22:36:44 [IT] DEBUG: Proxy : http://127.0.0.1:8118
2017-09-10 22:36:52 [scrapy.downloadermiddlewares.retry] DEBUG: Retrying <GET https://www.jobstreet.com.sg/en/job-search/job-vacancy.php?ojs=10&key=information%20technology> (failed 2 times): Connection was refused by other side: 61: Connection refused.
2017-09-10 22:36:52 [stem] DEBUG: GETCONF __owningcontrollerprocess (runtime: 0.0004)
2017-09-10 22:36:52 [stem] INFO: Error while receiving a control message (SocketClosed): empty socket content
2017-09-10 22:36:52 [IT] DEBUG: Proxy : http://127.0.0.1:8118
2017-09-10 22:36:56 [scrapy.downloadermiddlewares.retry] DEBUG: Gave up retrying <GET https://www.jobstreet.com.sg/en/job-search/job-vacancy.php?ojs=10&key=information%20technology> (failed 3 times): Connection was refused by other side: 61: Connection refused.
2017-09-10 22:36:56 [scrapy.core.scraper] ERROR: Error downloading <GET https://www.jobstreet.com.sg/en/job-search/job-vacancy.php?ojs=10&key=information%20technology>: Connection was refused by other side: 61: Connection refused.
2017-09-10 22:36:56 [scrapy.core.engine] INFO: Closing spider (finished)