SMTP login only works via AUTH PLAIN - phpmailer

This is my first time using telnet; I'm using it to debug PHPMailer. Here's what I get when logged in:
EHLO localserver.com
250-mx.zohomail.com Hello localserver.com (162.243.32.109 (162.243.32.109))
250-AUTH LOGIN PLAIN
250 SIZE 53477376
Following this tutorial, I try logging in via AUTH LOGIN.
When I give my password, it fails.
However, if I AUTH PLAIN, it works.
PHPMailer (I'm using the basic template provided at their git page with debugging set to 4) debugging shows me that they are using AUTH LOGIN.
So it seems that there are two ways to solve my problem.
-figure out why AUTH LOGIN doesn't work
-figure out how to get PHPMailer to use AUTH PLAIN.
Thanks

You can set the authentication type with the AuthType property. Just set it to PLAIN.
You don't need to use SMTPDebug = 4; 2 should be enough for this.

Related

passport-apple inexplainable invalid_client on nodejs backend -- using clean example repository with fresh set of credentials

I've cloned https://github.com/ananay/passport-apple-example and replaced the config with this:
clientID: "com.myname.web",
teamID: "myteamid",
callbackURL: "https://myurldev.com/auth/apple/redirect",
keyID: "mykeyid",
privateKeyLocation: path.join(__dirname, "../apple-key.p8")
I've also added SSL certificate on my machine and starting the server with https, all works fine & is recognized by my browser. I'm also starting the app on port 443 and proxying using my hosts file myurl.dev.com -> 127.0.0.1.
I have the same auth setup for facebook, google & microsoft and everything works fine.
I have:
Created a new APP identifier and enabled Sign in with Apple for it, named it: com.myname.dev
Created a new SERVICE identifier and enabled Sign in with apple, called it: com.myname.web
Added "https://myurldev.com/auth/apple/redirect" to the "Reply URLS" on the service identifier com.myname.web
Set my app identifier com.myname.dev as the main app identifier my service to be grouped with.
Created a private key and enabled sign in with apple, interface confirmed the presence of grouped ID com.myname.web bundled with com.myname.dev for which the key was created.
I have confirmed using console.log that the private key is indeed at the path being passed as parameter.
converted the .p8 file to base64 & then back to UTF-8 in an attempt to use the string for privateKeyString
successfully implemented Apple Oauth several times in the past using passport-apple
This time around, for some reason, auth simply doesn't work.
If I set the clientID as the APP identifier, not the service, I'm getting
invalid_request
Invalid web redirect url.
instead of invalid_client
Any advice on debugging this is highly appreciated. Thank you.
EDIT #1:
I have dug a bit deeper into the passport-apple package to figure out if anything goes against apple's docs around token generation, but the flow never reaches that part, indicating things go wrong on the actual configuration in Apple's console & what I'm trying to use for my project.
EDIT #2
2 of the app Ids I have created always throw "wrong redirect uri" because they're not service IDs so I can't configure redirect_uri, this will change if to "required" if I pass undefined as a redirect_uri.
One of the app ids throws only invalid client_id instead, regardless if I pass undefined or good value for redirect_uri.
EDIT #3
Went full vanilla through the OAuth code flow process and just created a url & redirected the user it, failing with this method is consistent with what is happening when using the passport-apple module.
const url = new URL("https://appleid.apple.com/auth/authorize");
url.searchParams.append("state", "fdbd287b1f");
url.searchParams.append("response_type", "code");
url.searchParams.append("scope", "name email");
url.searchParams.append("response_mode", "form_post");
url.searchParams.append(
"redirect_uri",
"https://raiseitupdev.com/auth/apple/redirect",
);
url.searchParams.append("client_id", "com.myname.web");
return res.redirect(url.toString());
[Creator of the library here.]
Did it stop working in development too? I feel this is a configuration error because the actual thing is working live on my website:
https://passport-apple.ananay.dev
Please follow up on this Github issue. Thanks!
https://github.com/ananay/passport-apple/issues/23

Send email via GMail SMTP in REBOL 2

I am new to REBOL. People blogging about how great REBOL is used sending an email as an example, similar to this example from the "send" documentation:
send luke#rebol.com "Testing REBOL Function Summary"
having read how easy and convenient it is to do this, I excitedly tried to send myself a test email via my GMail account.
I looked at the official GMail help for SMTP/POP to get the relevant SMTP/POP server names:
https://support.google.com/mail/answer/7104828?hl=en
And here is how far the "send" and "set-net" documentation got me:
>> set-net [ myrealusername#gmail.com smtp.gmail.com pop.gmail.com ]
>> send myrealusername#gmail.com "Hello me!"
connecting to: smtp.gmail.com
** Access Error: Cannot connect to smtp.gmail.com
** Where: open-proto
** Near: smtp-port: open [scheme: 'esmtp]
either only
On reflection, of course it didn't work; I told REBOL nothing about wanting to use SSL/TLS, the relevant port numbers, or my GMail password. It must need all of the above to actually send an email.
So how do I do it?
I modified the protocols some years ago to work with gmail. I hope that they still work.
You'll need to run both the prot-ssmtp.r and prot-ssend.r, and you'll need a version of rebol2 which supports ssl. This is either a free view build, or a paid core build.
do https://raw.githubusercontent.com/gchiu/Rebol2/master/Protocols/prot-ssmtp.r
do https://raw.githubusercontent.com/gchiu/Rebol2/master/Protocols/prot-ssend.r
Now, you can either set the user and password manually:
system/schemes/esmtp/user: "username"
system/schemes/esmtp/pass: "password"
or, when the script runs the very first time, you will be asked the values so that they can be set for that rebol instance. The prot-ssmtp uses port 465 but you can modify that if it's no longer correct.
And then it should be as straight forward after setting set-net as:
ssend email#someon.com "This is my message"
Note that we now have email on ren-c which is the open source fork of rebol3.

How can I get a token for the Drive API?

I want to implement the Google Drive API to my web application using NodeJS and I'm struggling when I try to get a token via OAuth.
I've copied the code from this guide and run the script using Node and it returns an error in this line:
var redirectUrl = credentials.installed.redirect_uris[0];
Googling around I found that I can set that variable as http://localhost:8080 and set the same value in the Authorized redirect URIs configuration in the Google Developers Console and that error goes away, fine, it works. Now it asks for a code that I should get by using an URL.
https://accounts.google.com/o/oauth2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&response_type=code&client_id=CLIENT_ID&redirect_uri=http%3A%2F%2Flocalhost%3A8080
Then I've added the client id and enter to that URL with Chrome and then returns a connection refused error. No clue what to do in here, I searched about my problem and I can't found an answer. By looking at the direction bar in Chrome I see that there's a parameter called code and after it, there's random numbers and letters. Like this:
http://localhost:8080/?code=#/r6ntY87F8DAfhsdfadf78F7D765lJu_Vk-5qhc#
If I add any of these values it returns this error...
Error while trying to retrieve access token { [Error: invalid_request] code: 400 }
Any ideas on what should I do? Thanks.
Did you follow all the directions on the page you indicated, including all of those in Step 1 where you create the credentials in the console and download the JSON for it? There are a few things to note about creating those credentials and the JSON that you get from it:
The steps they give are a little different from what I went through. They're essentially correct, but the "Go to credentials" didn't put me on the page that has the "OAuth Consent Screen" and "Credentials" tabs on the top. I had to click on the "Credentials" left navigation for the project first.
Similarly, on the "Credentials" page, my button was labeled "Create Credentials", not "Add Credentials". But it was a blue button on the top of the page either way.
It is very important that you select "OAuth Client ID" and then Application Type of "Other". This will let you create an OAuth token that runs through an application and not through a server.
Take a look at the client_secret.json file it tells you to download. In there, you should see an entry that looks something like "redirect_uris":["urn:ietf:wg:oauth:2.0:oob","http://localhost"] which is the JSON entry that the line you reported having problems with was looking for.
That "urn:ietf:wg:oauth:2.0:oob" is a magic string that says that you're not going to redirect anywhere as part of the auth stage in your browser, but instead you're going to get back a code on the page that you will enter into the application.
I suspect that the "connection refused" error you're talking about is that you used "http://localhost:8080/" for that value, so it was trying to redirect your browser to an application running on localhost... and I suspect you didn't have anything running there.
The application will prompt you to enter the code, will convert the code into the tokens it needs, and then save the tokens for future use. See the getNewToken() function in the sample code for where and how it does all this.
You need to use this code to exchange for a token. I'm not sure with nodejs how to go about this but in PHP I would post the details to the token exchange url. In javascript you post array would look similar to this ....
var query = {'code': 'the code sent',
'client_id': 'your client id',
'client_secret': 'your client secret',
'redirect_uri': 'your redirect',
'grant_type': 'code' };
Hope this helps
Change redirect uri from http://localhost:8080 to https://localhost:8080.
For this add SSL certificates to your server.

oauth2, imap, gmail - fetching mails - gmail api is down and can't find reference to oauth2

I have a requirement (flexible) to use oauth2. (existing architecture/code)
I have a need to do some text manipulation of subscriber's email headers.
Solutions I've tried.
I've tried to download the sample code for java and it correctly connects to gmail's imap servers. It however responds with oath_version=1 and is expecting a password. I've tried to massage the code to change the params as other api's like their Contacts api oauth2 without success.
Question:
(multipart)
Api is down:http://code.google.com/googleapps/domain/email_migration/developers_guide_java.html any reference online would be ideal (it has been down for at least half a week since last week Wed). If you wondered - yes I did post on their forums before asking here for the updated link.
Is there a way to: a) make oauth2 request and b) Any (minimal) code exaples I can look at would be great.
Thanks in advance for reading this post.
Here is a working, Ruby example of fetching email from Google using the OAuth2 protocol:
imap = Net::IMAP.new('imap.gmail.com', 993, usessl = true, certs = nil, verify = false)
imap.authenticate('XOAUTH2', 'example#gmail.com', 'oauth2_access_token_goes_here')
imap.select('INBOX')
imap.search(['ALL']).each do |message_id|
msg = imap.fetch(message_id,'RFC822')[0].attr['RFC822']
mail = Mail.read_from_string msg
puts mail.subject
puts mail.text_part.body.to_s
puts mail.html_part.body.to_s
end
Note: This example uses ruby mail gem and gmail_xoauth gem, so you will need those installed for this code sample to work. I am also using the omniauth and omniauth-google-oauth2 gems to handle logging the user in and using the access token.

Can't login to SharePoint using WebServices

I'm trying to access the files on a SharePoint-server(WOSS, 12.0.0.6421) through the WebServices but I can't sign in.
ListsService.Lists lists = new Lists();
lists.Credentials = new NetworkCredential("myusername", "mypassword", "mydomain");
lists.Url = "http://sharepointhost/_vti_bin/Lists.asmx";
XmlNode node = lists.GetListCollection();
return node.OuterXml;
But i get 401: unauthorized on GetListCollection, but the same username and password works perfectly when i access the sharepoint through a browser.
I checked the FAQ and found this: http://support.microsoft.com/default.aspx/kb/896861. But I'm not developing on the servering, I'm developing on another computer.
I found another thread which showed(http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/e115f790-fe8a-45e9-982b-21833ea01c7f) but when i use that solution I get "The HTTP request is unauthorized with client authentication scheme 'Ntlm'. The authentication header received from the server was 'NTLM'." which to me just seems even more confusing.
Try follwoing the steps mentioned in the link and this should solve your problem.
http://www.pentalogic.net/sharepoint-reminder/manual.aspx?Page=reminderservice%2fwssv3.htm
Tried and Tested - It worked for me.
HTH

Resources