using Mailer from /sender address laravel 5.7 - laravel-5.7

I have Mailer functionality built into my business app. I'm using smtp to send out client emails. The emails should be send from the client email address but instead are sent from the system. I do not have a default from address in my mail config file
Mail class:
public function build() {
$e_name=$this->name;
$e_email=$this->email;
$e_number=$this->number;
$e_subject=$this->subject;
$e_massage=$this->massage;
return $this->view('layout.sendmail')
->from($e_email)
->replyTo($e_email)
->subject($e_subject)
->with(compact('e_name','e_email','e_number','e_massage'));
}
Controller:
Mail::to('example#gmail.com')->send(new SendMail($name,$email,$number,$subject,$massage));

Related

Need to redirect from Web appplication to Zoho Desk

I have Zoho desk trail account.
We want to redirect from our web application to Zoho Desk Add Ticket page by clicking button.
I have configure SAML SSO from below mention link:
https://help.zoho.com/portal/en/kb/desk/for-administrators/user-access-and-security/articles/setting-up-saml-single-signon-for-help-center
How can i achieve this without login or auto signup/signin into Zoho Desk using SAML SSO?
Web application in .net core.
If any one have done this using code then please reply.
I have found one solution for this.
Download "Component SAML" package which is paid package, but you will get 30 day trial version or Install NuGet package "ComponentSpace.saml2".
Creates a self-signed X.509 certificate.
Upload public key on Zoho Desk SAML Configuration and add private key in your project (under certificate folder).
For Dot net core application you need to add below settings in appsettings.json file.
"SAML": {
"$schema": "https://www.componentspace.com/schemas/saml-config-schema-v1.0.json",
"Configurations": [
{
"LocalIdentityProviderConfiguration": {
"LocalCertificates": [
{
"FileName": "certificates/idp.pfx",
"Password": "password"
}
]
},
"PartnerServiceProviderConfigurations": [
{
"Name": "{Entity Id from Zoho desk SAML Screen}",
"SignSamlResponse": true,
"AssertionConsumerServiceUrl": {Help Center SAML Response URL}
}
]
}
]
},
"ZohoDeskSettings": {
"PartnerName": "{Entity Id from Zoho desk SAML Screen}",
"RelayState": "{url on which you want to redirect after SSO}"
}
Add below code in Startup.cs (ConfigurationService method)
services.AddSaml(Configuration.GetSection("SAML"));
Add below code in your controller from where you will click link to redirect to zoho portal
[Authorize]
[HttpGet]
public async Task<IActionResult> InitiateSingleSignOn()
{
// Get the name of the logged in user.
var userName = User.Identity.Name;
// For demonstration purposes, include some claims.
var attributes = new List<SamlAttribute>()
{
new SamlAttribute(ClaimTypes.Email, /*{Users Email}*/),
new SamlAttribute(ClaimTypes.GivenName, /*{Users FirstName}*/),
new SamlAttribute(ClaimTypes.Surname, /*{Users LastName}*/),
};
var partnerName = /*{Get setting from appsettings.json}*/;
var relayState = /*{Get setting from appsettings.json}*/;
// Initiate single sign-on to the service provider (IdP-initiated SSO)
// by sending a SAML response containing a SAML assertion to the SP.
// The optional relay state normally specifies the target URL once SSO completes.
await _samlIdentityProvider.InitiateSsoAsync(partnerName, userName, attributes, relayState);
return new EmptyResult();
}
You can also check example provided by Component SAML

.NET Core Identity - How generate token from another place than path/connect/token

in my web api application I get the acess token from http:applicationpath/connect/token with some parameters (this endpoint is from Identity I think, since we dont create it neither can see it).
But now I need to generate the token from a specific controller but cant see how to do this.
Someone knows how this can be made? Or even if it's possible?
Thanks
Some more info:
My application is an integrator (is this the word?) between an android app(app1) and other web application(app2).
1- The app1 user will send the login and password to my application .
2- Then my application will send then to the app2 who will, if everything goes well, return the app2 token .
3- Then I have to save this token in my db.
4- Then verify if the user exists in my db, and if not, save it.
5- And finally generate an token for my application and return it to the user.
Based on your comment:
But can I, instead of change de default endpoint, make another
endpoint that do the same (generate the token)?
it seems that you are rather looking for Extending discovery. This is quite easy actually.
Add a custom entry in the configuration of startup:
services.AddIdentityServer(options =>
{
options.Discovery.CustomEntries.Add("custom_token", "~/customtoken");
});
And add a controller that handles the request:
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
// In case a token is required for login, like the UserInfo endpoint:
//[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
[ApiController]
public class CustomTokenController : ControllerBase
{
[Route("customtoken")]
public IActionResult CustomTokenEndpoint()
{
return Ok();
}
}
Update
You can 'replace' the endpoint by disabling the default authorization endpoint and adding a custom endpoint as described above.
Disable the endpoint:
services
.AddIdentityServer(options =>
{
options.Endpoints.EnableAuthorizeEndpoint = false;
})
You may want to use the Authorize path constant.
public const string Authorize = ConnectPathPrefix + "/authorize";
Add the new endpoint:
services.AddIdentityServer(options =>
{
options.Discovery.CustomEntries.Add("authorization_endpoint", $"~/{Authorize}");
});
Please note, I didn't test it, but I think this should work.

symfony + ratchet : how to send msg to user from controller

i use ratchet to create chat. but i want to send message from controller to specific user. how i can access to $connections to find the user and sent the message
public function onOpen(ConnectionInterface $conn)
{
$this->connections[] = $conn;
}
i run server like this
$server = IoServer::factory(new HttpServer(
new WsServer(
new Notification($this->getContainer())
)
), 8080);
$server->run();
The best solution would probably be to use the SessionProvider:
http://socketo.me/docs/sessions
There are also simpler solutions, like using the connection id or a name for each connection.
Also, here's a great article on Ratchet with Symfony:
https://medium.com/#nihon_rafy/create-a-websocket-server-with-symfony-and-ratchet-973a59e2df94

Contact form 7 not getting email

I'm using contact form 7 and facing a problem with this email id, I'm not getting any mail what we can do for that. I used SMTP also.
could you please suggest me any other option.
have you checked spam folder ? Perhaps emails are in spam for email not get in spam you can use https://wordpress.org/plugins/wp-mail-smtp/
Here is setup documentation https://wpforms.com/docs/how-to-set-up-smtp-using-the-wp-mail-smtp-plugin/.
Please check may be helpful for you.
The best option is using PhpMailer library in php. You can check if the email was sent successfully using php mailer. All you need to do is to take all the library code and add it to your FTP or install it using composer.
Here is a simple example.
<?php
// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
// Load Composer's autoloader
require 'vendor/autoload.php';
// Instantiation and passing `true` enables exceptions
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 2; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = 'user#example.com'; // SMTP username
$mail->Password = 'secret'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
//Recipients
$mail->setFrom('from#example.com', 'Mailer');
$mail->addAddress('joe#example.net', 'Joe User'); // Add a recipient
$mail->addAddress('ellen#example.com'); // Name is optional
$mail->addReplyTo('info#example.com', 'Information');
$mail->addCC('cc#example.com');
$mail->addBCC('bcc#example.com');
// Attachments
$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
// Content
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Here is the subject';
$mail->Body = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
You can get all the information on PhpMailer here Php Mailer On Github
The PhpMailer is well configured so you don't have to worry about your emails ending up in Spam folder. Also be careful on the number of mails you send periodically to single recipients.

Custom Webhook Receiver in .Net core 2.1

I'm trying to create webhooks receiver for bigcommerce webhooks.
[HttpPost("customer_update")]
public void GetCustomerUpdateHook()
{
d_logger.Information("Process Webhook reply Web Response Hit");
}
my function is getting hit without any issues. But I don't know how to access the receiving data. I'm not sure how to use WebHookHandler.
framework => .Net core 2.1
controller => API Controller
I was able to receive the data, without using webhook handler or receiver. I just created a "POST" method in my controller by getting data from request body.
[HttpPost("customer_update")]
public void GetCustomerUpdateHook([FromBody] WebhookResponse p_data)
{
d_logger.Information("Process Webhook reply Web Response Hit");
var dataAsString = Newtonsoft.Json.JsonConvert.SerializeObject(p_data);
d_logger.Information("Response ==> {#data}", dataAsString);
}
But WebhookResponse class must match the data you are getting. for sender authentication, I added custom headers in Bigcommerce webhooks registration.

Resources