Can we change "apikey'" string in sendgrid - email

I am using sendgrid to send emails. I followed this guide to integrate SMTP relay.
In sendgrid they required "apikey" string to be set as username.
All configurations are successful but I am receiving email with this "apikey" string, like this: apikey <from_email_address>
This should be something like this instead of "apikey" string":
When I change the username (apikey in my case) then it starts showing bad username etc.
I'm new to sendgrid so not sure how we can achieve this but I believe no one would be sending emails to customers with this "apikey" string.

WSO2 Support team helped with this as it's a configuration which we need to set in deployment.toml file in WSO2 Identity server (I tried with version 5.11.0).
This block of code is required to configure sending email from WSO2 Identity server.
[output_adapter.email]
from_address= "wso2iamtest#gmail.com"
username= "wso2iamtest"
password= "Wso2#iam70"
hostname= "smtp.gmail.com"
port= 587
enable_start_tls= true
enable_authentication= true
signature = "ABC.com"
We need to add a value in signature = "Support" in order to receive emails with proper sender name. for example Support <test#support.com>
It is documented here:
https://is.docs.wso2.com/en/latest/setup/configuring-email-sending/

Related

Office365 SMTP with OAUTH2 client credentials flow returns "Authentication unsuccessful"

We have been trying to use Office365 SMTP OAUTH2 authentication with client credentials flow without success.
The documentation claims that SMTP should work
https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
but also states the following:
<<Note As per the current test with SMTP Oath 2.0 client credential flow with non-interactive sign in is not supported.">>
We can generate a token using the code interactive flow and with the delegation dynamic scope
https://outlook.office.com/SMTP.Send
The resulting token has scope "SMTP.Send" which can be used in JavaMail to successfully send emails from a specific user.
We are building a non-interactive application, the above does not work for us.
When we try to generate a token with the client credential flow, the only scope format supported is {resource}/.default
HTTP POST https://login.microsoftonline.com/{tenantid}/oauth2/v2.0/token
client_id=...
client_secret=...
grant_type=client_credentials
scope=https://outlook.office365.com/.default
There are no application's permissions for SMTP we can set under the Microsoft Office API.
Authentication always returns "535 5.7.3 Authentication unsuccessful"
This should work like IMAP does.
The only option we have found is to disable Security Defaults under
Azure Active Directory
-> Properties
-> Manage Security Defaults
Which enables PLAIN TEXT authentication.
You also need make sure that your emailbox does not have Smtp Client Authentication disabled with the following powershell command
Set-CASMailbox -Identity -SmtpClientAuthenticationDisabled $false
after these two changes JavaMail can authenticate using user/pwd and can send emails.
Per https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth:
Note As per the current test with SMTP Oauth 2.0 client credential flow with non-interactive sign in is not supported.
I just discovered this myself.
The Microsoft Graph API is an alternative option and I have confirmed it does work with the Client Credentials flow, but it has other limitations related to volume and file attachments to be considered.

Forward email using MailKit

I am trying to email EML files via Gmail SMTP server using MailKit. I followed example provided by jstedfast to build MimeMesage and send via Gmail SMTP server. I am able to send email using both the simple authentication using (user account, user password) and using OAUTH2. I followed example how to Setting up OAuth2 for use with Google Mail and all works fine, except that it seems that I have to configure access Scopes to include "https://mail.google.com/"
var accessScopes = new[]
{
"https://mail.google.com/",
"https://www.googleapis.com/auth/gmail.send"
};
otherwise sending fails with the following error:
535: 5.7.8 Username and Password not accepted. Learn more at
5.7.8 https://support.google.com/mail/?p=BadCredentials c5sm231676iod.25 - gsmtp
I assumed that I need to configure access scope with the gmail.send only but it doesn't seem to work.
"https://www.googleapis.com/auth/gmail.send"
I don't want to configure "https://mail.google.com/" which implies full access to the gmail account. When the consent screen is presented to users, users may hesitate to accept all access scopes which seems to be required otherwise sending of mails fails.
I tried to configure some of the read only scopes instead of "https://mail.google.com/" but it doesn't seem to work.
What I am missing?
Thank you
The "https://mail.google.com/" scope is the only scope that works with SMTP, POP3 and/or IMAP.
All of the other scopes are only available to use with the Google REST APIs.

keycloak configuration http-Link in "verify email"

When my users receive the "Please verifiy email link" the Link in the template is always: http://localhost:8280/auth....
First I tried to set the frontend URL in my realm:
But after this change I cannot start my quarkus-application anymore because I get the following error message: issuer validation error: received [https://myLinkToMyWebsite.com/auth/realms/turniersoftware]
So I removed this setting in keycloak.
I thought that keycloak is using this url for email broadcasts. "Quarkus-portal" is my java-application.
If I click impersonate user in keycloak and set the action "verifiy email" in keycloak admin web, I get the email verifiy email with the correct link.
If my java-program says "sendVerifyEmail" it will send out with "localhost:8280"
Can someone please explain me, what I have to configure to get the domain in my email broadcasts correct. Thank you
As per to the keycloak docs The default hostname provider uses the configured frontendUrl as the base URL for frontend requests (requests from user-agents) and uses the request URL as the basis for backend requests (direct requests from clients).
In your case I think the client configured is a Java client(which is backend) , so in order to force all the backend requests to pass through the public domain(frontendUrl) you might want to set the forceBackendUrlToFrontendUrl property to true in the standalone.xml file.
Please check the below link for further reference.
Hostname SPI

send gmail using powershell [duplicate]

This question already has answers here:
sending email with gmail using powershell
(3 answers)
Closed 4 years ago.
I'm developing a simply monitoring too for my home and I need it to send me an email. However, no matter what I try, it is not connecting to my gmail account to send the notification - or even a simple test message. I have a script that is working for a utility I wrote for work, but that is using the corporate SMTP relay. I'm not going to mix work and personal resources.
I have spent the past 4-5 weeks digging through this and trying several other development languages. All have come up with similar problems.
I have attempted the following:
Turned on less secure apps
Tried a variety of ports, 25, 465, 587
Turned on and off SSL
Tried various forms of my username (email address)
Turned on 2-factor authentication and created an app password for this utility
Attempted to turn on TLS - as one error indicated I needed a starttls command.
With Powershell, I seem to get two common errors. The first one is dependent on the parameters I'm sending to the Send argument - regardless, it fails.
[Screenshot of error - ][1]
I have been on multiple forums and sites. All of the suggested code appears to be all variants of the same structure, as is the working one for my office - just using our own mail system.
You should be able to use Send-MailMessage for this. Here's an example for sending an email securely using Gmail's SMTP server (including how to securely store your credential for further use later or in automation):
# Securely enter your Gmail credential
$cred = Get-Credential
# Store it off in a file if you want to reuse it later from the same box
# Password is encrypted and only your user on the same box can decrypt it
$cred | Export-CliXml \Path\To\GmailCredential.xml
# Import the credential from the file later
$cred = Import-CliXml \Path\To\GmailCredential.xml
# Send the mail message (use -BodyAsHtml instead of -Body if you have an HTML body)
$sendMailArguments = #{
SmtpServer = "smtp.gmail.com"
Credential = $cred
UseSsl = $true
Port = 587
To = "mailbox#domain.tld"
From = "youremail#domain.tld"
Subject = "Subject of the email"
Body = "Body of the email"
}
Send-MailMessage #sendMailArguments
Note that if you have Multi-Factor Authentication (MFA) set up you will need an app-specific credential to auth to Gmail, which would be a required step as well for setting up an email client for a Gmail account using MFA.
If you can't reach smtp.gmail.com, then it's likely you have a firewall blocking traffic to that server and port.
And if you want to better understand why I'm calling Send-MailMessage with a hashmap of arguments instead of specifying each parameter separately, see the comment discussion on this answer, and read up on Splatting here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_splatting?view=powershell-6

Discourse with sendgrid smtp: [Sender] 550 Unauthenticated senders not allowed

I have looked through every single bit of documentation I can find on this matter, and cannot figure this out. There must be people out there using Sendgrid as SMTP for discourse blogs, but I cannot figure out how.
Here's my app.yml setup:
env:
LANG: en_US.UTF-8
# DISCOURSE_DEFAULT_LOCALE: en
UNICORN_WORKERS: 3
DISCOURSE_DEVELOPER_EMAILS: 'admin#my_domain.com'
DISCOURSE_HOSTNAME: 'my_domain.com'
DISCOURSE_RELATIVE_URL_ROOT: /forum
## TODO: The mailserver this Discourse instance will use
DISCOURSE_SMTP_ADDRESS: smtp.sendgrid.net
DISCOURSE_SMTP_PORT: 587
DISCOURSE_SMTP_USER_NAME: apikey
DISCOURSE_SMTP_PASSWORD: API_KEY
DISCOURSE_SMTP_ENABLE_START_TLS: true
Obviously my_domain and API_KEY are replaced for the proper values. I have triple checked that these things are correct. I have rebuilt the app via launcher rebuild app many times.
The discourse admin UI shows these settings:
However, when I try to send any email, I get a popup that says:
There was a problem sending the test email. Please double-check your mail settings, verify that your host is not blocking mail connections, and try again.
The actual logs on the server aren't very helpful:
Sent mail to test#my_email.com (91.2ms)
Completed 422 Unprocessable Entity in 287ms (Views: 0.2ms | ActiveRecord: 0.4ms)
But when I check the "Skipped" tab of the admin email UI, I see that the "Skip Reason" is [Sender] 550 Unauthenticated senders not allowed - so I assume this is an authentication problem with SendGrid. How can I resolve this?
"Unauthenticated Senders not allowed" is a SendGrid-specific error that explicitly means that your system isn't sending the AUTH command. So even though you have authentication plain set, something is overriding that, and not attempting to authenticate when connecting to SendGrid.
Have you enabled "Mail Send" for that API Key?