Outlook Oauth - send emails with wl.imap scope in php - windows

I would like to automate sending few emails using Live Connect API.
I had been looking at this page here from the Live Connect SDK and i found is this :
http://msdn.microsoft.com/en-ca/library/hh243646.aspx : it is stating exactly :
wl.imap The wl.imap scope enables read and write access to a user's
email using IMAP, and send access using SMTP
I wanted to use that scope to use the smtp send email right, Im able to get the access token however there is no doc about how to communicate with smtp server etc...

You can follow this example that is for gmail:
http://www.chargenevier.com/2013/02/google-smtp-and-oauth2-authentication/
For outlook you need change this:
$config = array('ssl' => 'tls', 'port' => '587', 'auth' => 'oauth2', 'xoauth2_request' => $initClientRequestEncoded);
$transport = new Zend_Mail_Transport_Smtp('smtp-mail.outlook.com', $config);

Related

Not Getting Email using Gmail smtp on live server Laravel

I am on Laravel 5.6 and my application working well.
I am using Gmail SMTP for mail services.
here is my .env file.
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username#gmail.com
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls
I have already Turned ON Less secure apps in Gmail also turned ON 2 step verification.
From localhost, the mail system working like charm and I am getting all emails from Gmail SMTP.
But From Live Server, I am not getting any Emails and even there is no error popup.
My Host is a 000webhost free account because I am testing my Application.
so I read forums in 000webhost and change "SET MX RECORD " to "GOOGLE'S MX RECORD".
Now I am getting this error while sending any mail.
Expected response code 250 but got code "530", with message "530-5.5.1
Authentication Required. Learn more at 530 5.5.1
https://support.google.com/mail/?p=WantAuthError k142sm4568022ywa.67 -
gsmtp "
Please help!
Thanks in advance.
try changing your config/mail.php to your current credentials:
'driver' => env('MAIL_DRIVER', 'smtp'),
'host' => env('MAIL_HOST', 'smtp.gmail.com'),
'port' => env('MAIL_PORT', 587),
'encryption' => env('MAIL_ENCRYPTION', 'tls'),
'username' => env('MAIL_USERNAME', 'username#gmail.com'),
'password' => env('MAIL_PASSWORD', 'password'),
Please allow access to less secure app from your google account following these steps:
Go to your Google Account.
On the left navigation panel, click Security.
On the bottom of the page, in the Less secure app access panel, click Turn on access.
If you don't see this setting, your administrator might have turned off less secure app account access.

How to set up mailgun with laravel 5.7?

I am trying to set up mail sending with mailgun on my deployed laravel application. I am able to send email verification emails, but I can't send to my email. For example:
Notification::route('mail', 'admin#mywebsite.org')
->notify(new Feedback($user->email, $subject, $message));
When I was using mailtrap.io to test my mail sending it worked perfectly.
My .env file looks like this:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAILGUN_SECRET=key-<key>
MAIL_USERNAME=postmaster#sandbox<somenums>.mailgun.org
MAIL_PASSWORD=<mypass>
MAIL_ENCRYPTION=tls
When I try to send the email it brings this error: Expected response code 250 but got code "554", with message "554 Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings. "
welcome to SO.
Please have a deeper look at the Laravel official documentation where you can find everything you need to set up the mailgun driver.
Mailgun Driver
To use the Mailgun driver, first install Guzzle, then set the driver option in your config/mail.php configuration file to mailgun. Next, verify that your config/services.php configuration file contains the following options:
'mailgun' => [
'domain' => 'your-mailgun-domain',
'secret' => 'your-mailgun-key',
],
After updating your conf you have to change the MAIL_DRIVER env variable from smtp to mailgun. All the other settings for username, password and so on are not required.

Namecheap\Mailgun - receiving email

I am wondering how to setup namcheap and maligun to receive emails. Currently I am able to send emails with my laravel application through maligun, but I am not sure how to setup maligun to receives replies?
I have seen the options of setting up routes to receive emails to some wanted enpoint, but currently I am not receiving anything on maligun, so I have nothing to forward. I am getting the message:
This is the mail system at host eforward3e.registrar-servers.com.
I'm sorry to have to inform you that your message could not be
delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can delete your
own text from the attached returned message.
The mail system
: unknown user:
"support#my-domain.com"
Final-Recipient: rfc822; support#my-domain.com
Original-Recipient: rfc822;support#my-domain.com Action: failed
Status: 5.1.1 Diagnostic-Code: X-Postfix; unknown user:
"support#my-domain.com"
How should I set this up?
Hope you register your domain at mailgun, if not then do it here. Once your domain register follow below steps:
1) Get domain and API Key from Mailgun > Doamins > Domain Information page
2) Setup config/services.php:
'mailgun' => array(
'domain' => 'YOURDOMAINNAME',//Place your register domain name here...
'secret' => 'API Key',//Place your API Key here...
),
3) Setup .env:
MAIL_DRIVER=mailgun
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=USERNAME
MAIL_PASSWORD=YOURPASSWORD
MAIL_ENCRYPTION=tls
4) Check with sending mail from laravel application.
That's it...

OAuth2 password grant confusion

I have read below article and it is just awesome. Everything from that article is clear however I have one major doubt.
https://stormpath.com/blog/the-ultimate-guide-to-mobile-api-security
The article author said that in 'OAuth2 password grant' while logging into the mobile application, just need to send email and password in order to get the access token from the API server, but I have read at many places that you also need to send client_id and client_secret in that request. I'm going to build my API using Laravel:
https://laravel.com/docs/master/passport#password-grant-tokens
Here you can see it forces me to send client_id and client_secret in that request.
I'm really confused about this. If I have to send client_id and client_secret in that request, first I need to get it from the authorization server by creating a client on it. So at which event, I should create that client? When a user tries to log in from the mobile application? I just need to know the exact flow.
Any help would be appreciated.
Thanks
A client gets created for the developers who need to integrate with the OAuth2 server. It has nothing to do with the specific users' login flow.
ex. I want to integrate with Facebook login; I create a client on Facebook and incorporate that into my service, its Facebooks way of knowing who my service is.
So, a user logs in through your application; your application then sends that username and password to a backend server. The backend server then adds the client_id and secret so the OAuth server can verify the authenticity of the request.
So in your case, a user logs into your mobile application, you send that login request (username and password, with SSL) to your backend server. Your backend server then forwards that request to the OAuth2 service looking like the request below.
'form_params' => [
'grant_type' => 'password',
'client_id' => 'client-id',
'client_secret' => 'client-secret',
'username' => 'user#email.com',
'password' => 'user-password',
'scope' => '',
],
This directly returns an access_token and a refresh token that you can safely store in your mobile application.
I create the grant client in a migration called ConfigurePassport and set the key i want the app to use. You do not need a client per user.
public function up()
{
/*
* This command will create the encryption keys needed to generate secure access tokens.
* In addition, the command will create "personal access" and "password grant"
* clients which will be used to generate access tokens
*/
Artisan::call( 'passport:install', array('-n' => true) );
// Set Password Grant Client secret to known key
DB::table( 'oauth_clients' )->where( 'password_client', 1 )->update(
['secret' => env( 'GRANT_CLIENT_SECRET', 'dfhsdfhbtg545fdf45yedh5f5blahblah' )]
);
}
The above migration runs the artisan command passport:install as per the documentation to install the client. https://laravel.com/docs/master/passport#password-grant-tokens
Now your mobile app can request a token like so: the unique per user params are username and password.
You can find the client id in the oauth_clients table where password_client is true. It will likely be 2.
$http->post('http://your-app.com/oauth/token', [
'form_params' => [
'grant_type' => 'password',
'client_id' => 2,
'client_secret' => 'dfhsdfhbtg545fdf45yedh5f5blahblah',
'username' => 'taylor#laravel.com',
'password' => 'my-password',
'scope' => '',
],
]);
There are two different concepts:
Client: is the piece of software that's intended to communicate with your server. Usually, you will have 3 main clients which are your iOS, Android and web apps.
User: Which is the end-user that will interact with one of your clients, then the client will be communicating with the Oauth server on behalf.
So you will need to generate a client_id & client_secrete only one time. Then you can use these keys to be the authorized middle-man between your Oauth Server & the end-users.
In the case of Password Grant, The client_key & secrete_key are used to obtain the access_token for every user of each client you have.
Once the client obtains the access_token of a particular user (usually upon logging-in), the client will not need to send the client_key & secrete_key anymore, only the access_token.
However, if that user's access_token has expired, you will have to use those keys to exchange a new access_token with the refresh_token you already received from the login process.

Laravel - emails not sent using mandrill

I have mandrill configured for sending emails. Recently it stopped working so I tried to login to the mandrill account to find the following notice. I checked the MailChimp account and it was linked but still nothing is working. I have followed the documentation for sending using SwiftMailer but still nothing works.
In the documentation, it was stated to use MANDRILL_USERNAME and MANDRILL_PASSWORD. Are these the SMTP credentials is the account. If not, where can I find them in order to double check all configurations?
I'm using mandrill without problems but i have configured the service with a key to send emails.
This is how i do it:
Please check you have this in your .env:
MAIL_DRIVER=mandrill
MANDRILL_SECRET=kOAYRloydIXXXXXXXXXXXxxx
Next check your config/services.php
'mandrill' => [
'secret' => env('MANDRILL_SECRET'),
],
And your config/mail.php
'driver' => env('MAIL_DRIVER', 'mailgun'),
Hope this helps.

Resources