Sendgrid setup on SQL Database Mail - sendgrid

I have been trying to setup sendgrid on SQL Database Mail but all the time it says Cannot send mail to mail server.
This is what i have done.
I have sendgrid accound with abc#mydomain.com and created api key and SG.xxxx password.
As this is prod setup instance, i had done domain level authentication and my webmaster updated CNAME as requested by sendgrid.
Tested using TELNET smtp.sendgrid.net 587 and authenticated with SG.xxxx password Base64 encoded and this was able to send email from abc#mydomain.com to xyz#mydomain.com
I setup profile with abc#mydomoain.com as SQL notification Profile and selected Basic Authentication and provided 'apikey' as username and 'SG.xxx' as password in Database Mail - 'Configure Database Mail' option in SQL SSMS. Unchecked - 'The server requires secure authentication (SSL) connection' Port 587
I tried to 'Send Test Mail' with 'abc#domain.com' to 'xyz#mydomain.com' but the Database Mail reflects as below screenshot error
I have tried using abc#mydomain.com and sendgrid account password in Database Mail Config wizard for Basic authentication, but sendgrid suggested they don't accept Basic authentication. Please help how and where should i pass the api key if not under Basic Authentication ?
I tried updating with msdb.dbo.sysmail_add_account_sp nad updating records but it too didn't resolve and send email from Database mail.
Any help/ guidance would be greatly appreciated or if you had faced this how have you resolved it.

Hi the solution is as follows
Create a dbmail profile
server name: smtp.sendgrid.net
port : 25
SMTP Authentication
Basic Auth
User name: apikey
Password: : {the api-key for your sendgrid account}
Thats it. Send a test email.
If it still doesn't work, if you are on AWS EC2 ensure that security group allows outbound port:25
Here is the link from sendgrid about apikey authentication.
https://docs.sendgrid.com/for-developers/sending-email/upgrade-your-authentication-method-to-api-keys

Related

Gmail SMTP Authentication Error when using App password with workspace domain alias

I want to be able to use my Google Workspace email alias when automating email sending using yagmail and gmail's SMTP server.
I have set the default "Send Email As" address from the main email (#gmail.com) to the alias email (#domain.com), which is fine when sending manually. I currently have 2SV enabled with my main email & app password sending emails properly through yagmail, but it still shows the sending address as the main email. I tried authenticating with the email alias and a new app password, but I am receiving the following error:
smtplib.SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted).
I tried a few solutions found online, such as this one (https://support.google.com/mail/thread/127655543/gmail-alias-not-working-it-says-the-password-i-am-entering-for-the-alias-is-wrong-but-it-s-correct?hl=en), to no avail.
Why is using App password fine for my main email but not my domain alias? How can I automate sending emails using domain alias? Any help on this would be greatly appreciated!

Has anyone configured SMTP relay for Outbound Emails in G Suite?

Has anyone been able to route outgoing mail through Google using another non-Gmail SMTP service?
I currently have a website running with Bitnami vm running a CanvasLMS application on a Google Cloud Platform server.
When entering my GSuite Gmail Advanced Settings, the required steps have been done to configure the SMTP relay service. (TLS set to true)
https://support.google.com/a/answer/2956491?hl=en&authuser=3&ref_topic=2921034
I have also configured the setup for the outgoing email server at /apps/canvaslms/htdocs/config/outgoing_mail.yml (replacing username and password with my application's credentials)
production:
enable_starttls_auto: true
address: smtp-relay.gmail.com
port: 587
user_name: USERNAME#gmail.com
password: PASSWORD
authentication: plain # plain, login, or cram_md5
domain: smtp-relay.gmail.com
outgoing_address: USERNAME#gmail.com
default_name: CANVAS LMS
Saved the changes and restarted the server. When trying to send an email in Canvas for new user registration, it never reaches the receivers email inbox.
I have reviewed my application logs and have not discovered any errors related to this
Any thoughts on troubleshooting this SMTP issue???
https://docs.bitnami.com/installer/apps/canvaslms/configuration/configure-smtp/
https://community.canvaslms.com/t5/Question-Forum/emails-are-not-sent-to-users-students/m-p/230561#M128347

Jenkins SMTP Configuration - 535 Authentication Failed

I'm trying to configure Jenkins email notification via Mailer plugin 1.21.
I'm using secureserver.net as a mailing server.
I have a problem with "SMTP Authentication", the "Test configuration" is reporting 535 Authentication:
Failed to send out e-mail
javax.mail.AuthenticationFailedException: 535 Authentication Failed
for jenkins#xxxx.com
at
com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:809)
at
com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:752)
at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:669)
at javax.mail.Service.connect(Service.java:317) at
javax.mail.Service.connect(Service.java:176) at
javax.mail.Service.connect(Service.java:125) at
javax.mail.Transport.send0(Transport.java:194) at
javax.mail.Transport.send(Transport.java:124)
My settings are as follows:
SMTP server: smtpout.secureserver.net
Use SMTP Authentication: yes
User Name: jenkins#xxxx.com
Password: ******
Use SSL - yes
SMTP Port - 465
Charset - UTF-8
I'm using the same credentials to connect via webmail: https://email11.secureserver.net/webmail.php. I don't have a connection problem.
Do you have any explanation why jenkins refuse to authenticate?
As google doesn't allow login from less secure apps you have do the following steps:
1. Login to "https://myaccount.google.com/security"
2. Enable "Allow less secure apps" to "ON"
Then check the "Test configuration" in jenkins.
From https://products.secureserver.net/email/email_outlook.htm:
NOTE: "smtpout.secureserver.net" is an SMTP relay server. In order to
use this server to send e-mails, you must first activate SMTP relay on
your e-mail account. Log on to your Manage Email Accounts page to set
up SMTP relay.
Did you do this?
I solved similar issue by creating a new SMTP credential from AWS SES.
But I am still amazed why old credentials didn't work with jenkins even if it was working with other applications.

SwiftMailer not send mail with Google App account

I'm using Symfony and I'm trying to send an email with swiftmailer. I have an account set up with google app (produccion#mydomain.com) and when I try to send shows me the following error:
Failed to authenticate on SMTP server with username
"produccion#mydomain.com" using 2 possible authenticators
I tried it with my personal gmail account and send the message correctly with the same settings. Just change the username and password.
# Swiftmailer Configuration
swiftmailer:
transport: smtp
host: smtp.gmail.com
username: produccion#mydomain.com #email#gmail.com
password: google_app_password #gmail_password
auth_mode: login
port: 587
encryption: tls
I've been searching the internet and I've found this page from Google, where I can change the access to less secure applications.
https://www.google.com/settings/security/lesssecureapps
In my gmail account this option is active, but if I turn shows me the same error when sending email.
I've been trying to change this setting in google app account but it tells me that this option is not available for google app.
Any idea to send emails from this account by google app? I have to set something else?
EDIT
It seems Gmail prefers OAuth, Swiftmailer supports this authentication mech but its not really documented.
https://developers.google.com/gmail/xoauth2_protocol
https://github.com/swiftmailer/swiftmailer/blob/5.x/lib/classes/Swift/Transport/Esmtp/Auth/XOAuth2Authenticator.php
Any idea how I use it in Symfony?
Have you tried setting the transport parameter to gmail as mentioned in the cookbook? http://symfony.com/doc/current/cookbook/email/gmail.html
# Swiftmailer Configuration
swiftmailer:
transport: gmail
username: your_gmail_username
password: your_gmail_password

Symfony 2 Swiftmailer + Amazon SES: Failed to authenticate on SMTP server with username "XXXXXXXXXXXXXXXX" using 2 possible authenticators

I know this question have been asked before but any of the given responses read have become into a solution for this scenario with Symfony2 + Swiftmailer + Amazon SES.
I setup Amazon SES account details for Swiftmailer in Symfony2, all the information is correct, user name and password. However by some weird reason I don't catch up Symfony2 Swiftmailer drops me this error while sending the email.
Failed to authenticate on SMTP server with username "XXXXXXXXXXXXXXXX" using 2 possible authenticators
This is what I got in config.yml
#app/config/config.yml
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
port: "%mailer_port%"
encryption: "%encryption%"
username: "%mailer_user%"
password: "%mailer_password%"
And parameters.yml
#app/config/parameters.yml
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1
database_port: null
database_name: mydatabase
database_user: dbuser
database_password: dbpass
mailer_transport: smtp
mailer_host: email-smtp.us-east-1.amazonaws.com
mailer_port: 587
encryption: tls
mailer_user: XXXXXXXXXXXXXXXX
mailer_password: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
mailer_from: support#mycompany.com
locale: en
secret: ThisTokenIsNotSoSecretChangeIt
debug_toolbar: true
debug_redirects: false
use_assetic_controller: true
Placing a Gmail smtp details instead Amazon SES works just fine and sends email rightly. But with Amazon SES configuration it doesn't. I repeat, user name is correct, it works with Amazon SES Mailer library, but does not do it with Symfony integrated Swiftmailer.
Some thoughts?
I know this is an old question, but I just want to add something, since I passed the last 3 hours trying to solve this exact problem.
From Symfony V4.0, the configuration of Swift Mailer is done like this, trough enviroment variables:
MAILER_URL=smtp://email-smtp.us-east-1.amazonaws.com:587?encryption=tls&username=YOUR_SES_USERNAME&password=YOUR_SES_PASSWORD
As showed here.
The problem is that is an URL, so that means that if the string has any special characters, they need to be encoded, in this case the password had a plus on it eg. :
AKD23$ADADADJJ$123123LKIOU8jUIJ8j+9IJHJW8JNN4nnn2
This refused to work, until I changed to this:
AKD23$ADADADJJ$123123LKIOU8jUIJ8j%2B9IJHJW8JNN4nnn2
This completely solved the problem once and for all.
All your configuration parameters I think are just fine like in the Symfony2 documentation states http://symfony.com/doc/current/cookbook/email/cloud.html
If with the Amazon SES Mailer library which is part of the AWS SDK it works, then check if you are using the right credentials for the SMTP solution with Swiftmailer in Symfony2.
When you use the AWS SDK you use the AWS access keys to access the SES API and be able to send email using the Amazon SES Mailer included in that SDK.
When you use another library like Swiftmailer you'll be sending email via the Amazon SES SMTP interface it requires the SMTP credentials, not the AWS access keys.
This SMTP credentials are generated from the SMTP settings in the SES console and those are the right ones that should be used when using SMTP to send email with amazon SES.
Check this documentation
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/using-credentials.html
For posterity, you can create SMTP credentials via the console as explained in the Obtaining Your Amazon SES SMTP Credentials document.
As I found out the hard way, it's rather easy to generate the wrong type of IAM credentials and then wonder why you're failing authentication. :)