Google SMTP returns required authentication but it's done as an app password - smtp

I am setting up SMTP service on Airflow 2.1.2.
I get this error which is quite obvious:
smtplib.SMTPSenderRefused: (530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError w5sm3433302wra.87 - gsmtp'
But authentication is done, i am using an email that has 2 steps authentication, so I created an app password and I recognized the activity in google account security tab..
My setup is:
AIRFLOW__EMAIL__EMAIL_BACKEND airflow.utils.email.send_email_smtp
AIRFLOW__SMTP__SMTP_HOST smtp.gmail.com
AIRFLOW__SMTP__SMTP_MAIL_FROM my email
AIRFLOW__SMTP__SMTP_PASSWORD my app pwd of 16 chars
AIRFLOW__SMTP__SMTP_PORT 587
AIRFLOW__SMTP__SMTP_SSL False
AIRFLOW__SMTP__SMTP_STARTTLS True
AIRFLOW__SMTP__SMTP_USER my email
I checked and there is no extra space or something like that neither in pwd or email.
Why is it returning required authentication when authentication is really done?

Not sure why it is not working. But do you see:
Fetching SMTP credentials from configuration variables will be deprecated in a future warning? You should if your environment variables will be used.
If you do not see it, then you likely have smtp_default connection in the Connection database.
In Airflow 2 the authentication for SMTP has been brought to the same level as other connections and rather than passing user/password via environment variable, they should be configured as login/password in the 'smtp_default' connection.
The variables should still work as fallback, but if you already have smtp_default connection created and has some login/password (even empty) configured, those will be used instead of the ENV vars.
In your case likely the solution will be to set login/password in the connection.

Related

Msmtprc SMTP with Office365

I am configuring msmtprc smtp to send an outbound email and having a trouble with office365. It's working fine with Gmail account, but I am getting the following error with office 365.
msmtp: authentication failed (method LOGIN)
msmtp: server message: 535 5.7.3 Authentication unsuccessful [BN6PR13CA0016.namprd13.prod.outlook.com]
msmtp: could not send mail (account default from /etc/msmtprc)
/var/log/msmtp.log
Authentication unsuccessful [BN6PR13CA0016.namprd13.prod.outlook.com]' errormsg='authentication failed (method LOGIN)' exitcode=EX_NOPERM
/etc/msmtprc
defaults
auth on
logfile /var/log/msmtp.log
account office
host smtp.office365.com
port 587
protocol smtp
from support#example.net
user support#example.net
password *******
tls on
tls_starttls on
tls_trust_file /etc/pki/tls/certs/ca-bundle.crt
Does anyone successfully use Msmtprc with office365?
Thank you.
I've been successfully using msmtp fine for quite some time, using the following settings (on a CentOS 7 box), but with the config in $HOME/.msmtprc since it's just for my user rather than globally:
account default
host smtp.office365.com
port 587
tls on
tls_starttls on
tls_trust_file /etc/ssl/certs/ca-bundle.crt
tls_certcheck on
auth on
user username#example.com
passwordeval pass office365.com
from username#example.com
logfile ~/.msmtp.d/msmtp.log
..so this is 99% the same as yours except that instead of having the password in the file I'm using passwordeval to provide it via the output of the given command.
Perhaps multiple spaces between password and the password itself is causing the spaces to be added to the start of the password?
You could also try running msmtp so that it has a controlling terminal (i.e. run from the shell rather than via the service manager as with systemctl) to test whether providing it the password that way works as expected?

Failure Sending Mail using GSuite SMTP

I have a very curious issue with an application. When debugging locally, I can send emails just fine using a client's G Suite email credentials:
<smtp deliveryMethod="Network" from="client#customdomain.com">
<network defaultCredentials="false"
host="smtp.gmail.com"
port="587"
userName="client#customdomail.com"
password="supersecret"
enableSsl="true" />
</smtp>
Now, it's very important to note that the application will send just fine with the credentials when running on localhost using Visual Studio. However, when deploying to LIVE and using the exact same credentials, the application refuses to send and I only get the canned response back saying "Failure Sending mail".
I have enabled "less secure applications" in the settings and have verified the "suspicious activity" from the server's IP address. I can also log in to the Gmail account from the server using RDP and opening Firefox to go to Gmail.com.
No firewall rule has been set to block SMTP or anything on port 587.
UPDATE: the materialized error message is
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.192.108:587
74.125.192.108 being smtp.gmail.com's IP Address (or one of them, at least)
UPDATE 2: I can also not get Thunderbird on the remote server to send an email using the supplied credentials, however it can connect via IMAP and download the contents of the inbox just fine.
Well in this very specific case, it was the fault of the Amazon infrastructure this application ran on. Either amazon themselves, or the reseller changed a policy that ended up blocking communications on ports 465, 587 and 993 (and probably others too).
The "solution" was to nag them to sort it out.

Issue with Roundcube on Postfix, Dovecot, MySQL

I am seasoned with Ubuntu, Apache and MySQL but new to the email server world and an looking for some troubleshooting tips with my server configuration.
I am running Ubuntu 14.04 with Postfix, Dovecot and MySQL as instructed in this tutorial: https://www.digitalocean.com/community/tutorials/how-to-configure-a-mail-server-using-postfix-dovecot-mysql-and-spamassassin
with the exception of spamassassin.
I then installed postfixadmin to provide a graphical means of configuring my virtual postfix users/domains.
Thereafter I installed Roundcube as instructed in this tutorial: http://www.unixmen.com/install-configure-roundcube-webmail-ubuntu/ with the exception of the version (I am using 1.1.4). Everything checks out; I can Telnet into my mail server with accounts created using postfixadmin and can verify the mailbox(es) exists. The server receives email from external domains and can send as well. However, when I attempt to login to a verified user account via-Roundcube it fails. I have tried and tried again to find what is missing and have hit a wall.
Any suggestions would be greatly appreciated.
Best Regards,
-Joe
To debug, I would double check that RC is configured correctly to communicate with dovecot: this is the piece of software that is going to handle the authentication. To verify the software settings, one could switch on the debugging of both RC and dovecot.
Check RC configuration files to make sure that it is set up to connect to the right server and port. These settings can be found either in 'config.inc.php' or in 'defaults.inc.php' under the 'config' directory of RC. Look for IMAP section and the following strings:
$config['default_host'] = 'tls://localhost';
$config['default_port'] = 143;
$config['imap_auth_type'] = null;
Pay special attention to the 'tls://' ('ssl://') prefixes -- these control the usage of encryption during negotiation with IMAP server (tls issues STARTTLS command while connecting on a standard port, and ssl expects connection to be encrypted from the very start and thus is generally used to connect to a dedicated 'encryped' port): for the purposes of debugging one might want to disable encryption altogether. I would propose to use the same hostname and port as were used for telnetting.
If these settings seem to be right, one can proceed to debugging of IMAP connection from RC to dovecot. To enable debugging, edit defaults.inc.php once again:
$config['debug_level'] = 1;
$config['log_driver'] = 'syslog';
$config['syslog_id'] = 'roundcube';
$config['syslog_facility'] = LOG_MAIL;
$config['log_logins'] = true;
$config['imap_debug'] = true;
This would direct debug information of RC IMAP negotiation with dovecot to /var/log/mail.log, where you most probably would be able to identify the problem.

Using domain mail server for sendmail

The piece of php script is:
$sendmail=1;
$sendmail_path='/path/to/sendmail';
$smtp_server='localhost';
My webhost want me to use my domain smtp mail server mail.xxxxx.net instead of "localhost" otherwise sendmail is blocked.
I don't know how to reset the script.
Please help me
Thanks
One of the settings that you tried
<?php
$smtp_server='mail.telugugreetings.net';
is actually a correct setting, as indicated by its error message:
Additional errors: 550 Access denied - Invalid HELO name (See RFC2821 4.1.1.1)
This is an SMTP error, so you have successfully connected to your SMTP server. This error indicates a completely different problem:
4.1.1.1 Extended HELLO (EHLO) or HELLO (HELO)
These commands are used to identify the SMTP client to the SMTP server. The argument field contains the fully-qualified domain name of the SMTP client if one is available. In situations in which the SMTP client system does not have a meaningful domain name (e.g., when its address is dynamically allocated and no reverse mapping record is available), the client SHOULD send an address literal (see section 4.1.3), optionally followed by information that will help to identify the client system. y The SMTP server identifies itself to the SMTP client in the connection greeting reply and in the response to this command.
Make sure that you are setting the "From" field properly. It should probably be something ending in #telugugreetings.net. Without knowing more about your mail server and your PHP code, including any libraries you may be using to send mail, I can't be more specific.
You might need to contact your hosting provider again to ask about this new error message.
The PHP manual's mail() Runtime configuration says:
Used under Windows only: host name or IP address of the SMTP server PHP should use for mail sent with the mail() function.
Click Here for PHP Mail Runtime configuration
Is this on you local Windows machine?
Are you hosting on a Windows machine?
If not Windows the SMTP directive is ignored.
If you have a Windows machine:
The PHP setting for SMPT is a "PHP_INI_ALL, Entry can be set anywhere"
Which mean this directive can be set Runtime, in:
php.ini, .htaccess, httpd.conf or .user.ini
Get you SMPT Configurations Setting:
echo ini_get('SMTP');
To Set you SMTP
ini_set ('SMTP', $SMPTServer)
Where $SMPTServer is the host name or IP address of the SMTP server PHP should use for mail sent.

Need help setup windows server 2008 SMTP server

I am trying to setup windows server 2008 smtp server to relay emails to gmail smtp. Everything appears to be setup but it is not sending emails. Could you please help me figure out whats wrong.
Below is the setup:
Windows server 2008 with SMTP server
feature installed. Need SMTP server
to forward all messages to gmail smtp
server to send.
I have google apps setup for my
domain, also I can send emails
throught my test app using
gmail smtp.
SMTP Server Configuration: By default has default smtp server virtual directory.
In Properties of that virtual smtp server changed following.
Fully qualified domain name = mydomain.com
smart host = smtp.gmail.com
TCP Port = 587
Out Bound Security = Basic Authentication(my username password for google apps email account)
In domains list under virtual smtp server. I have one default domain that's server dns. I added another one for my domain name.
With above setup i am trying to redirect all email to gmail smtp.
I tested connection to smtp.gmail.com from server on port 587 through telnet and it works.
I am trying to use above server from my web application also by just dropping emails in pickup directory. It get's picked up and also accepts request form web application but never sends an email.
I can see that it adds those emails in queue folder but it stays there forever.
When i try to send emails from web app to above server it rejects if To address is other than my domain.(Am i missing something in list of domains)
Thanks for all answers, finally found solution there is a property for maximum sessions which value was 0 by default. Changed it to 100 and it send all pending emails immediately.
Possible reasons are that some SMTP servers block the outgoing messages if there domain name mismatch, possible to prevent spam mails from being sent. So for example, I will not be able to send my email with an address abc#mydomain.com from my domain yourdomain.com.
Hope that helps.
Ensure your sending domain is the same as the google apps domain
Ensure your sending address is a real address and not just an alias
IIRC you need to use STARTTLS (SSL) not basic authentication
This souds like a DNS issue. Check your /badmail directory. It will have .bad and .bdp files in there. You can open these in notepad (there will be some binary in there).
However, it may point to the possible problem.
You may also want to try and enable logging on the SMTP service. There may be something in there.