9

I want to send email in my php/laravel app in ubuntu 18 under Digital Ocean and I found this https://semantiko.com/how-to-fix-php-mail-function-on-ubuntu-server/ article I filled related config files and send several email and I found in console:

grep -riI ssmtp /var/log
...
/var/log/mail.log:Oct 24 14:05:22 nsn-do-lamp sSMTP[16500]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/mail.log:Oct 24 14:05:22 nsn-do-lamp sSMTP[16500]: Authorization failed (534 5.7.14  https://support.google.com/mail/answer/78754 b5-v6sm5187045wrr.94 - gsmtp)
/var/log/mail.log:Oct 24 14:05:23 nsn-do-lamp sSMTP[16502]: Creating SSL connection to host
/var/log/mail.log:Oct 24 14:05:23 nsn-do-lamp sSMTP[16502]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/mail.log:Oct 24 14:05:23 nsn-do-lamp sSMTP[16502]: Authorization failed (534 5.7.14  https://support.google.com/mail/answer/78754 t198-v6sm6776812wmd.9 - gsmtp)
/var/log/dpkg.log:2018-10-24 05:27:56 install ssmtp:amd64 <none> 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status half-installed ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 configure ssmtp:amd64 2.64-8ubuntu2 <none>
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status unpacked ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status half-configured ssmtp:amd64 2.64-8ubuntu2
/var/log/dpkg.log:2018-10-24 05:27:56 status installed ssmtp:amd64 2.64-8ubuntu2
/var/log/syslog.1:Oct 24 05:34:07 nsn-do-lamp sSMTP[10100]: Creating SSL connection to host
/var/log/syslog.1:Oct 24 05:34:07 nsn-do-lamp sSMTP[10100]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 24 05:34:07 nsn-do-lamp sSMTP[10100]: Authorization failed (534 5.7.9  https://support.google.com/mail/?p=WebLoginRequired 130-v6sm4756430wmn.7 - gsmtp)

and under my account in https://mail.google.com I found email :

Sign-in attempt was blocked
myaccount@gmail.com
Someone just used your password to try to sign in to your account from a non-Google app. Google blocked them, but you should check what happened. Review your account activity to make sure no one else has access.
CHECK ACTIVITY

Clicking on "CHECK ACTIVITY" button next page was opened https://i.stack.imgur.com/9a3pz.jpg and I want TO PERMIT my account or me, to be used so I click on "NO, SECURE ACCOUNT" and next page is opened https://i.stack.imgur.com/zyvTs.jpg

that was rather strange for me, as I do not need to change the password. I want to permit mail service to use my gmail.com account.

Can you say what is wrong ?
Did I misunderstand gmail messages ?

MODIFIED BLOCK # 2 I tried to follow the provided link and I opened the next instructions :

Use this setting when you want to ensure that access by a less secure app is unavailable to all. Sign in to your Google Admin console. Sign in using an administrator account, not your current account MyNick@gmail.com

... Who is my administrator? Quick definition: A person who manages Google services or devices for a company, school, or group. Someone in your company, school, or group Your current account, MyNick@gmail.com, isn’t managed by an administrator. The account isn’t associated with any company, school, or group. Instead, it’s a free Google Account that you can manage yourself.

But reading the docs I missed as I am free Google Account is there is a way to make myself as administrator? If yes, please point where and how ?

MODIFIED BLOCK # 3: In my conf files 587 port is used: sudo nano /etc/ssmtp/ssmtp.conf :

root=MYNICK@gmail.com
mailhub=smtp.gmail.com:587
hostname=smtp.gmail.com:587
UseSTARTTLS=YES
AuthUser=MYNICK@gmail.com
AuthPass=MYPASSWORD
FromLineOverride=YES
UseTLS=YES

sudo nano /etc/ssmtp/revaliases :

root:MYNICK@gmail.com:smtp.gmail.com:587

After modifing of thesae files I run command service apache2 restart

and testing sending email I do not recieve emails on my email and I see a lot of “Authorization failed” errors in next log

grep -riI ssmtp /var/log
var/log/syslog.1:Oct 30 00:34:04 nsn-do-lamp sSMTP[24892]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 00:34:04 nsn-do-lamp sSMTP[24892]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 00:34:05 nsn-do-lamp sSMTP[24892]: Authorization failed (534 5.7.14  https://support.google.com/mail/answer/78754 y76-v6sm12958494wmd.37 - gsmtp)
/var/log/syslog.1:Oct 30 01:34:04 nsn-do-lamp sSMTP[25660]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 01:34:04 nsn-do-lamp sSMTP[25660]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 01:34:04 nsn-do-lamp sSMTP[25660]: Authorization failed (534 5.7.14  https://support.google.com/mail/answer/78754 60-v6sm16580038wra.35 - gsmtp)
/var/log/syslog.1:Oct 30 02:34:05 nsn-do-lamp sSMTP[26444]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 02:34:05 nsn-do-lamp sSMTP[26444]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 02:34:05 nsn-do-lamp sSMTP[26444]: Authorization failed (534 5.7.14  https://support.google.com/mail/answer/78754 t16-v6sm274794wrr.12 - gsmtp)
/var/log/syslog.1:Oct 30 03:34:06 nsn-do-lamp sSMTP[27101]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 03:34:07 nsn-do-lamp sSMTP[27101]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 03:34:07 nsn-do-lamp sSMTP[27101]: Authorization failed (534 5.7.14  https://support.google.com/mail/answer/78754 m16-v6sm13164091wmd.35 - gsmtp)
/var/log/syslog.1:Oct 30 04:34:04 nsn-do-lamp sSMTP[27852]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 04:34:04 nsn-do-lamp sSMTP[27852]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 04:34:05 nsn-do-lamp sSMTP[27852]: Authorization failed (534 5.7.14  https://support.google.com/mail/answer/78754 143-v6sm17450782wmv.6 - gsmtp)
/var/log/syslog.1:Oct 30 05:34:04 nsn-do-lamp sSMTP[28734]: Creating SSL connection to host
/var/log/syslog.1:Oct 30 05:34:04 nsn-do-lamp sSMTP[28734]: SSL connection using ECDHE_RSA_CHACHA20_POLY1305
/var/log/syslog.1:Oct 30 05:34:04 nsn-do-lamp sSMTP[28734]: Authorization failed (534 5.7.14  https://support.google.com/mail/answer/78754 b5-v6sm1822874wrf.15 - gsmtp)

1) Can be some more services I need to restart apart apache2

2) It seems to me that these log messages are not last, as running :

 # date
Tue Oct 30 12:02:40 UTC 2018

I see time difference, like that were no last message rows Is there is a way to clear ssmtp logs?

3) Which is safe way to restart ubuntu 18 under Digital Ocean, without droplet damage ? In some case that I am not sure if have I to restart some service I prefer to restart the system...

MODIFIED BLOCK # 4: Thank you for your feedback! I tried to follow you instructions : 1) I activated two factor authentication : https://i.stack.imgur.com/174Zb.jpg. But if have I do to something with these apps?

2) I got password https://i.stack.imgur.com/S60UJ.jpg in format XXXX XXXX XXXX XXXX

3) after password creation I got next page https://i.stack.imgur.com/9NJ38.jpg:

4) You mentioned

“use the app password in your .env file”

which must be name of var of this password? Like in

AuthPass=MYPASSWORD # password without spaces in it?

in /etc/ssmtp/ssmtp.conf or some other name ? Only this new password generated I need ?

Thanks!

4 Answers4

3

Enabling less secure apps to access accounts

  1. Sign in to your Google Admin console.
  2. Click Security > Basic settings.
  3. Under Less secure apps, select Go to settings for less secure apps.
  4. In the subwindow, select the Allow users to manage their access to less secure apps radio button.

Once you've set Allow users to manage their access to less secure apps to on, affected users within the selected group or Organizational Unit will be able to toggle access for less secure apps on or off themselves.

Reference Allow or disallow less secure apps to access accounts

David Cash
  • 29
  • 3
2

We've had similar problems when we used some "fresh" gmail addresses from our Google Apps for work account. Seems that Google has some kind of heuristic running for new addresses that block app access from unknown apps.

Our solution was to enable 2-factor-authentication and subsequently generate an app password. Steps:

Hirnhamster
  • 7,101
  • 8
  • 43
  • 73
  • Please look at MODIFIED BLOCK # 4 –  Oct 31 '18 at 12:30
  • 1
    Put this password in `ssmtp.conf` in place of the old one and it should work. It will not require a second authentication factor. – swapgs Nov 02 '18 at 12:04
0

For your edit block #2, you can't make yourself administrator with a regular Google account. To be your own administrator, you have to pay for G Suite. https://gsuite.google.com/

G Suite is not for personal. It is for businesses that want to use Google applications for their company. This will give them the management panel in admin.google.com where they can change a wide range of settings to add and edit accounts, use own business mail, change logo for applications and much more. (Even device management for Android, IOS and Chromebook.) I am an IT from my company and we use G Suite. Those prices are too high for testing. So, it is impossible to be your own administrator because it's too expensive for yourself.

Edit to give you a pricing list: https://gsuite.google.com/pricing.html

Best regards, Chris

Chris van Chip
  • 504
  • 4
  • 20
0

Updated instructions for enabling Less Secure App

  1. From Gmail click on the gear icon (top right)
  2. Click on See all Settings
  3. Accounts and Imports tab
  4. Click on Other Google Account Settings
  5. Left or top menu, Security
  6. Scroll down to Less Secure App Access, turn it on