SMTP error with CodeIgniter and SparkPost - codeigniter

I use the email library to send mail using SMTP.
I was using Mandrill, and all was working fine.
I now use SparkPost, and I have irregular error. CI Library returns blank error once in a while. The exact same mail can work ten times and fail one.
My config :
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'smtp.sparkpostmail.com';
$config['smtp_user'] = '****';
$config['smtp_pass'] = '****';
$config['smtp_port'] = '587';
$config['smtp_crypto'] = 'tls';
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['useragent'] = "BioCRM";
$config['wordwrap'] = FALSE;
$config['mailtype'] = "html";
$this->email->initialize($config);
Here are examples of errors I get with print_debugger()
> Example 1:
> hello:
> The following SMTP error was encountered:
> starttls: 220 2.0.0 smtp.sparkpostmail.com ESMTP ecelerity 4.2.21.55447 r(Core:4.2.21.2) Thu, 09 Jun 2016 05:46:19 +0000
>The following SMTP error was encountered:
>Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.
>Example 2:
>hello: 220 2.0.0 smtp.sparkpostmail.com ESMTP ecelerity 4.2.21.55447 r(Core:4.2.21.2) Wed, 08 Jun 2016 14:08:44 +0000
>The following SMTP error was encountered: 220 2.0.0 smtp.sparkpostmail.com >ESMTP ecelerity 4.2.21.55447 r(Core:4.2.21.2) Wed, 08 Jun 2016 14:08:44 +0000
>
>starttls: 250-momentum4.platform1.us-west-2.aws.cl.messagesystems.com says EHLO to 89.31.151.18:39185
> 250-ENHANCEDSTATUSCODES
> 250-8BITMIME
> 250-AUTH=LOGIN PLAIN
> 250-AUTH LOGIN PLAIN
> 250-PIPELINING
> 250 STARTTLS
> The following SMTP error was encountered: 250-momentum4.platform1.us-west-2.aws.cl.messagesystems.com says EHLO to 89.31.151.18:39185
> 250-ENHANCEDSTATUSCODES
> 250-8BITMIME
> 250-AUTH=LOGIN PLAIN
> 250-AUTH LOGIN PLAIN
> 250-PIPELINING
> 250 STARTTLS
> The following SMTP error was encountered: .0.0 continue
>Example 3:
>hello:
>The following SMTP error was encountered:
>starttls:
>The following SMTP error was encountered:
>The following SMTP error was encountered: .0.0 smtp.sparkpostmail.com ESMTP ecelerity 4.2.21.55447 r(Core:4.2.21.2) Wed, 08 Jun 2016 12:59:08 +0000
As I get those errors only with Sparkpost, I asked them, and here is their answer :
The errors you’ve pasted are regular parts of the SMTP conversion. For example 1:
“starttls: 220 2.0.0 smtp.sparkpostmail.com ESMTP ecelerity 4.2.21.55447 r(Core:4.2.21.2) Thu, 09 Jun 2016 05:46:19 +0000”
Start TLS is a banner advertise to let people know we accept TLS connections. 220 is a proper code and means it’s ready to accept.
Smtp.sparkpostmail.com is the hostname of the server you’ve connected to.
ESMTP is the protocol that is being used
Ecelerity 4.2.21.55447 r(Core:4.2.21.2) is the name and version number of the service that is handling this connection and the SMTP conversation, which is broadcasted when a connection is made.
(And of course, the time stamp.)
This, however, seems like an error on your application: “Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.”
For example 2, the response is similar, but the placement is odd. We don’t send a EHLO more than once so likely your application did not like the EHLO and reported the error after the other status codes were sent. “.0.0 continue” looks like a truncated part of the SMTP conversation, which should look more like this
data
354 3.0.0 continue.  finished with "\r\n.\r\n"
I'm not sure your application is interpreting those as errors, as they're all standard parts of the SMTP conversation. Since there are so many different jumps, it's certainly possible that your application is timing out or packets could be dropped between jumps. I would check to make sure if there are any packets dropped in the conversation (as that may be why you application is not recognizing the lines) and if not, why your application is not recognizing parts of the SMTP conversation. Thank you.
Does it mean something to one of you ?
Thank you very much

Related

NiFi InvokeHTTP POST invalid request

I am trying to execute a simple POST request from nifi using the InvokeHTTP processor. The target server responds with the response "error: invalid request". I am able to POST successfully with curl from nifi's host.
I have set the processor's HTTP method to "POST", and the URL to "http://myhost:1234", other fields are set to the defaults. The incoming flowfile's mime.type is application/json and the flowfile content is valid json.
Here's what I tried (server names etc. were replaced with fake names):
I confirmed that the target server is ok with curl using seemingly equal parameters to the InvokeHTTP processor (with and without the --http2 flag, equally on the InvokeHTTP processor I tried with the "HTTP/2 Disabled" property on true and false):
curl -v --http2 -POST -H "content-type: application/json" http://myhost:1234/ -d '\[{"key":"value"\]'
For the data I used the actual content of the flowfile used by InvokeHTTP.
* Trying <ip>...
* TCP_NODELAY set
* Connected to myhost (<ip>) port 1234 (#0)
> POST / HTTP/1.1
> Host: myhost:1234
> User-Agent: curl/7.61.1
> Accept: */*
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA
> content-type: application/json
> Content-Length: 17
>
* upload completely sent off: 17 out of 17 bytes
< HTTP/1.1 201 Created
< Server: <servername>
< Content-Length: 0
<
* Connection #0 to host myhost left intact
With InvokeHTTP, the response is routed to the NoRetry output with the following attributes added to the flowfile:
invokehttp.response.body
error: invalid request
invokehttp.response.url
http://myhost:1234/
invokehttp.status.code
400
invokehttp.status.message
Forbidden
I tried logging the request by setting the org.apache.nifi.processors.standard.InvokeHTTP logger to DEBUG. The resulting logs:
2022-11-17 11:22:03,384 DEBUG [Timer-Driven Process Thread-4] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=<guid>]
Request to remote service:
http://myhost:1234/
date: Thu, 17 Nov 2022 11:22:03 GMT
user-agent:
2022-11-17 11:22:03,384 DEBUG [Timer-Driven Process Thread-4] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=<guid>]
Request to remote service:
http://myhost:1234/
date: Thu, 17 Nov 2022 11:22:03 GMT
user-agent:
2022-11-17 11:22:03,391 DEBUG [Timer-Driven Process Thread-4] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=<guid>]
Response from remote service:
http://myhost:1234/
content-length: 23
server: <servername>
2022-11-17 11:22:03,391 DEBUG [Timer-Driven Process Thread-4] o.a.nifi.processors.standard.InvokeHTTP InvokeHTTP[id=<guid>]
Response from remote service:
http://myhost:1234/
content-length: 23
server: <servername>
At this point I don't know what to do. I don't know if the logged requests are purposefully limited to these fields or if there's actually a lot of information missing from the requests themselves such as the payload and the content type. I'm also wondering why the requests are logged twice, or whether they're actually sent twice (I'm on a single node environment).
I expect this processor to be able to perform such a simple request without much trouble, and have confirmed that the target server is not the issue. Did I miss something? How can I debug this further (e.g. see the actual raw request sent by InvokeHTTP)?
Thank you.
Check the mime.type attribute. That is automatically translated to a header for you, and you could be sending form-encoded parameters as the mime type or something like that instead of the expected json.

Unable to upgrade https to websocket in envoy (https to ws upgrade)

I'm using the following code to upgrade https connection websocket connection receiving 403 error.
https to ws upgrade
Configuration:
match:
safe_regex:
google_re2: {}
regex: "/api/1/(web|rest)/ws.*"
upgrade_configs:
- upgrade_type: websocket
Access logs shows as upgrade_failed with 403 code and debug logs shows the following
':authority', 'localhost'
':path', '/api/1/rest/ws'
':method', 'GET'
'sec-websocket-version', '13'
'sec-websocket-key', 'winoU3MVKB9q2s02lVj7ug=='
'connection', 'Upgrade'
'upgrade', 'websocket'
'sec-websocket-extensions', 'permessage-deflate; client_max_window_bits'
[2022-11-01 15:48:09.757][21026][debug][http] [external/envoy/source/common/http/filter_manager.cc:883] [C2183][S8415942046573715112] Sending local reply with details upgrade_failed
[2022-11-01 15:48:09.757][21026][debug][http] [external/envoy/source/common/http/conn_manager_impl.cc:1400] [C2183][S8415942046573715112] closing connection due to connection close header
[2022-11-01 15:48:09.757][21026][debug][http] [external/envoy/source/common/http/conn_manager_impl.cc:1455] [C2183][S8415942046573715112] encoding headers via codec (end_stream=true):
':status', '403'
'date', 'Tue, 01 Nov 2022 15:48:09 GMT'
'server', 'envoy'
'connection', 'close'
Any insights what might be the issue.

Spring Boot - Tomcat - Apache2 - HTTP 503 Error - ProxyIOBufferSize

I have installed my Spring Boot application at an Ubuntu version 18 server.
I use apache2 and lets encrypt to secure the application with SSL.
The application works fine in 95%, sometimes I get a HTTP 503 error at the client (Browser debugging view)
If HTTP 503 appears at the Browser/Client an entry is also made at apache2 log file which looks like this:
[Thu Mar 26 00:10:52.731383 2020] [proxy_ajp:error] [pid 16266:tid 139926293157632] [client
xxxx.xxxx.3.59:60869] AH00893: dialog to 127.0.0.1:9090 (localhost) failed, referer:
https domain
[Thu Mar 26 00:10:57.802571 2020] [proxy_ajp:error] [pid 16266:tid 139926720988928]
(70014)End of file found: AH01030: ajp_ilink_receive() can't receive header
[Thu Mar 26 00:10:57.802597 2020] [proxy_ajp:error] [pid 16266:tid 139926720988928] [client
xxx.xxx.3.59:60875] AH00992: ajp_read_header: ajp_ilink_receive failed, referer:
https domain
[Thu Mar 26 00:10:57.802628 2020] [proxy_ajp:error] [pid 16266:tid 139926720988928]
(120006)APR does not understand this error code: [client xxx.xxx.3.59:60875] AH00878: read
response failed from 127.0.0.1:9090 (localhost), referer: https domain
I found this thread:
We did some more investigation and found that the Apache setting that enables packets > 8192
(ProxyIOBufferSize 65536) was not going into effect because it was wrapped in an <IfModule
... > condition. (The module is loaded but we are investigating why the condition isn't
satisfied.) Tomcat 8.5 worked because it never sent packets larger than 8192, even though it
was allowed to, Tomcat 9 is sending bigger packets as it is configured to. With
ProxyIOBufferSize outside of the conditional, it is now working as expected.
My question now would be if it is possible that the size of ProxyIOBufferSize is to small and how can I adjust ProxyIOBufferSize in apache2 config file.
You can change ProxyIOBufferSize Directive of Module mod_proxy ref : https://httpd.apache.org/docs/2.4/mod/mod_proxy.html#proxyiobuffersize
Edit proxy section of /etc/apache2/sites-enabled/000-default.conf :
<Proxy>
ProxyIOBufferSize 65536
</Proxy>

Apache2/Laravel responding 301 on some agents

I have wifidog installed on a TP-LINK
(openwrt 18.06.2)
I have wifidog-auth-laravel installed on a OVH Debian
github /wifidog/wifidog-auth-laravel)
If I use curl, chrome and wget; I get the pong response for the authetication url
But if wifidog attempts to get the pong response I get a 301 Permanantly moved response.
How can that be?
[7][Mon May 20 13:44:54 2019][5977](centralserver.c:302) Level 1: Connecting to auth server example.com:80
[7][Mon May 20 13:44:54 2019][5977](centralserver.c:331) Level 1: Successfully connected to auth server example.com:80
[7][Mon May 20 13:44:54 2019][5977](centralserver.c:141) Unlocking config
[7][Mon May 20 13:44:54 2019][5977](centralserver.c:141) Config unlocked
[7][Mon May 20 13:44:54 2019][5977](centralserver.c:147) Connected to auth server
[6][Mon May 20 13:44:54 2019][5977](wd_util.c:116) AUTH_ONLINE status became ON
[7][Mon May 20 13:44:54 2019][5977](simple_http.c:77) Sending HTTP request to auth server: [GET /ping/?gw_id=EC086B35444C&sys_uptime=1820&sys_memfree=6096&sys_load=0.70&wifidog_uptime=3 HTTP/1.0
User-Agent: WiFiDog 1.2.1
Host: example.com
]
[7][Mon May 20 13:44:54 2019][5977](simple_http.c:87) Reading response
[7][Mon May 20 13:44:54 2019][5977](simple_http.c:111) Read 725 bytes
[7][Mon May 20 13:44:54 2019][5977](simple_http.c:124) HTTP Response from
Server: [HTTP/1.1 301 Moved Permanently
Date: Mon, 20 May 2019 13:44:54 GMT
Server: Apache/2.4.25 (Debian)
Location: http://example.com/ping?gw_id=EC086B35444C&sys_uptime=1820&sys_memfree=6096&sys_load=0.70&wifidog_uptime=3
Content-Length: 415
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved here.</p>
<hr>
<address>Apache/2.4.25 (Debian) Server at example.com Port 80</address>
</body></html>
]
[4][Mon May 20 13:44:54 2019][5977](ping_thread.c:191) Auth server did NOT say Pong!
[7][Mon May 20 13:44:54 2019][5977](firewall.c:140) Marking auth server down
I found the solution:
The Wifidog userAgent formed the url different from the other user agents:
a workaround is in the wifidog.conf
AuthServer {
Hostname example.com
SSLAvailable yes
Path /
PingScriptPathFragment ping?
LoginScriptPathFragment login?
PortalScriptPathFragment portal?
MsgScriptPathFragment gw_message.php?
AuthScriptPathFragment auth?
}

SMTP connection disconnecting after giving message Authorizing to server, working with james server and outlook

I am working with Apache James 2.3 and while Outlook tries to send emails to the server. I get the below smtp conversation and then the connection closes. I have configured the Outlook with the required authentication credentials.
But I still seems to not be able to pinpoint where is it going wrong, as I am only able to get the connection is initiated log on the James server side and no Mailets are being hit.
Port: 587, Secure: TLS, SPA: no
Finding host
Connecting to host
Connected to host
<rx> 220 XXXX SMTP Server (JAMES SMTP Server) ready Thu, XXXXXXXXX 08:39:20 +0000 (GMT)
[tx] EHLO XXXXXXXXXXX
<rx> 250-XXXX Hello XXXXXXXXXXX (XXX.XXX.XXX.XXX [XXX.XXX.XXX.XXX])
<rx> 250-SIZE 102400000
<rx> 250-STARTTLS
<rx> 250-PIPELINING
<rx> 250 ENHANCEDSTATUSCODES
Securing connection
[tx] STARTTLS
<rx> 220 Go ahead
Securing connection
Connected to host
[tx] EHLO XXXXXXXXXXX
<rx> 250-XXXX Hello XXXXXXXXXXX (XXX.XXX.XXX.XXX [XXX.XXX.XXX.XXX])
<rx> 250-SIZE 102400000
<rx> 250-STARTTLS
<rx> 250-PIPELINING
<rx> 250 ENHANCEDSTATUSCODES
Authorizing to server
Disconnecting from host
Disconnected from host
The server does not advertise any authentication mechanisms - there is no 250-AUTH reply to EHLO.

Resources