Email process in Hybris not working - email

I am a newbie to Hybris and I got a task to configure mail service in the application.
The code for the mail is already written but still the mail is not working.
I tried to configure it and the smtp configuration is fine. I am using SMTP configuration of Google.
However, when I execute the process, it breaks at the very first node quoting :
Something Went Wrong
I am using the following link :
http://flexblog.faratasystems.com/index.php/ecommerce-with-hybris-sending-emails/
<process xmlns="http://www.hybris.de/xsd/processdefinition"
start="generateOneMillionPurchaseEmail"
name="oneMillionPurchaseProcess"
processClass="com.project.model.OneMillionPurchaseProcessModel"
onError="error">
<action id="generateOneMillionPurchaseEmail" bean="generateOneMillionPurchaseEmail">
<transition name="OK" to="sendEmail"/>
<transition name="NOK" to="error"/>
</action>
This is the very first node : generateOneMillionPurchaseEmail
but when I execute it, its not working.
Can anyone suggest anything on how to get it done ?

First guess without any logs:
get fakeSMTP (https://nilhcem.github.io/FakeSMTP/) and try to it as a local service by setting the value
mail.smtp.server=127.0.0.1
As google requires a authentication to use there SMTP Service, a local version without any authentication would be a good first test.

Related

How can I host a web.config-only server?

Context
See this question: Enable CORS on Azure Service Bus Namespace
Really I want to have a front-end only ReactJS app that talks to the Azure API, and renders bits of the result onto the screen. Then gets input from the users and sends that back to the Azure API. Rinse and repeat.
Unfortunately CORS pretty much rules that out, and you can't[1] override the CORS rules for a ServiceBus Namespace.
So the proposed solution is a thin proxy server, proxying the Azure API, to circumvent CORS.
(Alternative solutions to this question are HIGHLY welcome!)
[1] read: I can't currently see any way to, and nor can my Google Searches.
Question
The user on that other question proposes the relevant web.config file, so now I want to create that proxy server. I don't really want that server doing anything else, I want it to be as transparent as possible.
What is the simplest possible way to set up that server?
I'm kinda hoping that I would be able to do something like:
"Tell Azure that I want a webserver, and paste/upload that web.config text into the Azure Portal"?
If it's relevant, currently my stack has literally nothing other than npm and the JS Create-React-App template's stack. I'm imagining we'll host the site in Azure too.
I got this to work, and it was pretty painless - Azure can JustDoThis.
Documenting the notes I wrote for myself here, for any future lost wanderers :)
As noted in the linked question, the Azure server doesn't (and can't) enable CORS, so we need to circumvent that in some manner. The approach is to create a ReverseProxy server, which accepts the request, forwards it to Azure, receives the response, adds the relevant CORS headers and and returns it to the caller.
Followed steps, except skip the "Basic Authentication" step (Steps #3 & #4), from this Microsoft blog: https://blogs.msdn.microsoft.com/mihansen/2018/04/18/reverse-proxy-with-basic-authentication-in-azure-web-app/
Step 1: Create a new Azure Web App
Step 2: Add applicationHost.xdt file (in \Home\site)
Step 2a: Set the contents of the .xdt file using provided template (I think it's literally a web.config file?
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.webServer>
<proxy xdt:Transform="InsertIfMissing" enabled="true" preserveHostHeader="false" reverseRewriteHostInResponseHeaders="false" />
</system.webServer>
</configuration>
SKIP STEPS 3 & 4 (relate to Authentication which isn't necessary if it's just a redirect.)
Step 5: Update/Modify/Create rewrite rules
Step 2 is achieved through KUDU, which is accessible here:
https://yourazuresitedomain.scm.azurewebsites.net/
Some links about what KUDU is and how to use it:
https://blogs.msdn.microsoft.com/benjaminperkins/2014/03/24/using-kudu-with-windows-azure-web-sites/
https://www.jamessturtevant.com/posts/How-to-add-edit-and-remove-files-in-your-azure-webapp-using-the-kudu-service-dashboard/

Unrecognised attribute 'enableSsl' in .NET v4.0

We've been running a new system in test for a while now and creating emails to a folder so they don't accidentally go out to clients. Now we've turned on live emailing we are getting issues with sending.
I'm using ActionMailer.NET and the code to create and send the email is below. I won't include the View:
EmailResult x = new EmailController().EmailWorkOrderForApprovalToClient(model);
System.Net.Mail.Attachment file = new System.Net.Mail.Attachment(FilePath);
x.Mail.Attachments.Add(file);
x.Deliver();
Which gives the error
The SMTP server requires a secure connection or the client was not
authenticated. The server response was: 5.7.57 SMTP; Client was not
authenticated to send anonymous mail during MAIL FROM
The web.config looks like this:
<system.net>
<mailSettings>
<smtp deliveryMethod="Network" from="ClientServices#topupconsultants.com">
<specifiedPickupDirectory pickupDirectoryLocation="" />
<network defaultCredentials="false" host="smtp.office365.com" password="secret" port="587" userName="ClientServices#myco.com" />
</smtp>
</mailSettings>
My assumption is that enableSsl="true" needs to be added to the network line, but when I do that and try to go to the SMTP Email section of the site in IIS, I get the error:
Unrecognized attribute 'enableSsl'
I'm not that hot on IIS, but I've checked that the Application Pool and its .NET CLR version is 4.0.30319. I've also checked that .NET v4.5 is installed on the server.
This is baffling me, and I'm hoping I don't have to totally change my code to a method that allows me to specify SSL at that point.
Answering my own question here, and basically the answer is: "Don't believe the error message". In all the configurations I tried, I believed the error message when it told me that is was unacceptable. However, I tried it anyway, and it uses the enableSsl attribute when it sends, and this allows the connection to Office 365 to succeed.
Slightly irritating IIS bug that I'll forget about in a week, but right now is very annoying.
This is issue on IIS no need to worry about this error message
SmtpClient object enableSsl value get mapped
this silly issue is wasted my much time :D

Unexpected 401.5 error. Authentication header changed to Kerberos?

This problem seems to exist on a specific server. All other servers are working ok.
Background: The website is basically Forms Auth but there's an asmx that manually requires Basic Auth.
I have two C# client.
When invoking using SOAP (asmx client proxy) with basic auth credentials - all is well.
When invoking using WebClient or WebRequest with the same basic auth credentials, I get 401.5.
The folders have "Everyone" set to them.
When setting up iis trace, I see a very weird behavior. The request arrives with the correct Basic auth header. But further down the trace I see the following:
GENERAL_REQUEST_HEADERS
Headers="Connection: Keep-Alive
Content-Length: 68
Content-Type: application/json
Authorization: Kerberos
Expect: 100-continue
Host: 1.2.3.4
The Kerberos seems very weird. It is as if the request headers changed throughout the process, and perhaps that explains the 401.5.
Again, I would like to stress out that on other servers there's no problem with both clients. The only difference I can think of is that the problematic server is a DC. But if that is a problem then why is the SOAP client working well?
Any ideas?
Progress!
After some debugging I noticed that Application_AuthenticateRequest was fired twice for every request. The first time with Basic auth as I expected and the second time with the Kerberos!
After googling I found this:
http://forums.asp.net/t/1868629.aspx?HttpModule+triggered+two+times+for+request+to+URL+without+default+document
Seems like for extensionless urls those events might fire multiple times, depending on the configured Extensionless urls.
Going back to the trace I noticed that in the non-working server the trace shows usage of ExtensionlessUrl-ISAPI-4.0_64bit, and in the working servers no such entry existed. After comparing the two IIS I noticed that the non-working IIS had ExtensionlessUrl-ISAPI-4.0_64bit configured whereas in the working IIS there was ExtensionlessUrl**Handler**-ISAPI-4.0_64bit (note the "handler"). I compared the dlls involved and the working server had a newer aspnet_isapi.dll. I assume that this is an updated extensionless url handler. I suppose an upgrade to IIS or .NET might install a later version, but for now I tried to remove the ExtensionlessUrl-ISAPI-4.0_xxbit like so:
<remove name="ExtensionlessUrl-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrl-ISAPI-4.0_64bit" />
And it worked! Now there is only a single Application_AuthenticateRequest.
The non-working version that had this in the trace:
OldHandlerName="", NewHandlerName="ExtensionlessUrl-ISAPI-4.0_64bit", NewHandlerModules="IsapiModule", NewHandlerScriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll", NewHandlerType=""
Now changed to:
OldHandlerName="", NewHandlerName="WebServiceHandlerFactory-ISAPI-4.0_64bit", NewHandlerModules="IsapiModule", NewHandlerScriptProcessor="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll", NewHandlerType=""
Hopefully that's the end of it. Additional testing still required.
I would appreciate if someone can write how to upgrade IIS dlls to a later version. Is this an upgrade to .NET or is there a specific KB update that is downloaded with Windows Update?

WebMatrix how can you enable the POST method

I have a form action that I am trying to use, but, when I submit the form, I get the HTTP Error 405.0 - Method Not Allowed.
<form action="" method="post">
I am using WebMatrix on my local machine. I have been told that I need to enable the POST method within WebMatrix through a configuration file or something, but can't find anything that tells me how to do that.
If you're having ASP.NET Running on WebMatrix, then you must have IIS server in your computer too. So, for that you need to be looking for methods and codes to make the web.config work with IIS.
On the following page it has been told how you can allow or deny types of Requests.
http://www.petefreitag.com/item/741.cfm
security --> requestFiltering -->
<verbs allowUnlisted="false" applyToWebDAV="true">
<add verb="GET" allowed="true" />
<add verb="POST" allowed="true" />
</verbs>
Furthermore, you can see that IIS is disabled to accept HttpGet and HttpPost requests by Default. http://support.microsoft.com/kb/819267/en-us Go to the link and learn how to enable them.
I hope it allows that.
Secondly, also try using POST instead of post. Maybe that would be an issue in IIS. Do try this second method.

when I add "<Runtime executionContext="elevated" />" to my web role definition, and attempt to deploy, it fails to start

When I add "" to my ServiceDefinition.csdef, it fails to start when publishing:
<WebRole name="xxx" vmsize="Small" enableNativeCodeExecution="true">
<Runtime executionContext="elevated" />
<Sites>...
Everything works with it gone. Need to add it to specify machine key in Azure SDK 1.3, as described here: http://msdn.microsoft.com/en-us/library/gg494983.aspx
Anyone else run into this?
Would running under admin privileges cause other code to break? When I RDP in, the error I find when I run on localhost is not related to this, but it's code that works when this runtime line is removed.
I just checked the Service Definition Schema and the Runtime
element does not exist inside WebRole.
Actually it does.
<WebRole name="<web-role-name>" vmsize="[ExtraSmall|Small|Medium|Large|ExtraLarge]" enableNativeCodeExecution="[true|false]">
...
<Runtime executionContext="[limited|elevated]">
I just checked the Service Definition Schema and the Runtime element does not exist inside WebRole.
If you would like to have Full Trust, you should go to yor CloudService project properties and set it there. But i really don't know if you need that to specify the machine key.
Best regards