0

I am using this curl:

curl -vvv --url 'smtp://smtp.office365.com:587' \
--ssl-reqd \
--mail-from "$user" \
--mail-rcpt "$destuser" \
--upload-file ./mail.txt \
--oauth2-bearer $accesstoken

to try to send an email from an account where I registered an oauth application with these Graph Permission - Delegated Permissions

SMTP.Send
Mail.Read
Mail.Send
openid
offline_access

but I always get error: 530 5.7.57 Client not authenticated to send mail.

both the user mailbox and the transport have SmtpClientAuthenticationDisabled to $false

I am quite confident that the access token is valid, I also tested the refresh token which works, any idea on how to make this work?

Is curl compatible with https://docs.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth

?

golemwashere
  • 734
  • 1
  • 10
  • 22
  • managed to authenitcate manually with: XOAUTH2="user=$user\001auth=Bearer $token\001\001" echo -en $XOAUTH2 | base64 > encodedtoken.txt tr -d '\n' < encodedtoken.txt > encnonewline.txt helo="myserver.com" from='sender@test.com' to='dest@gmail.com' subj="subject: test mail" data=" hello test mail" encoded2=$( cat encnonewline.txt ) – golemwashere Mar 13 '22 at 10:21
  • { sleep 1 echo "helo $helo" sleep 0.5 echo "auth xoauth2" sleep 1 echo $encoded2 sleep 3 echo "mail from:<$from>" sleep 0.5 echo "rcpt to:<$to>" echo "data" echo "From: $from" echo "To: $to" echo "$subj" echo echo "$data" echo "." sleep 1 echo quit } | timeout 15 openssl s_client -connect smtp.office365.com:587 -crlf -starttls smtp > ./output.txt 2>&1 cat ./output.txt still need to understand how to do with curl – golemwashere Mar 13 '22 at 10:21

0 Answers0