getgrav / grav-plugin-email

Grav Email Plugin
http://getgrav.org
MIT License
37 stars 29 forks source link

Cannot send emails using smtp.gmail.com #65

Closed alfre22 closed 6 years ago

alfre22 commented 6 years ago

Hi, I'm trying to configure Gmail SMTP server to sending emails for a website developed on Grav CMS.

I set the email plugin configuration according to documentation and I use a contact form to receive feedback from my clients.

These are my settings (file /user/config/plugins/email.yaml):

enabled: true
from: myaccount@gmail.com
from_name: 'My Name'
to: myaccount@gmail.com
to_name: 'My Name'
mailer:
  engine: smtp
  smtp:
    server: smtp.gmail.com
    port: 587
    encryption: tls
    user: myaccount@gmail.com
    password: MyPassword
  sendmail:
    bin: /usr/sbin/sendmail
content_type: text/html
debug: false

I've activated IMAP service on my Gmail settings, allowed access for less secure apps and activated DisplayUnlockCaptcha on the account I'm using.

Everything seems working and I can send several emails for testing, but after a while emails are not sent anymore. I dont' know what is happening. Maybe Gmail is banning the system?

This site receives low traffic, I'm not expecting more than a couple emails per week.

Thanks in advance!

rhukster commented 6 years ago

Please test with the CLI command to make sure email is being sent properly. See the README.txt for details

alfre22 commented 6 years ago

Another idea? I have no ssh access to my server because is not available for my hosting plan. :-/

rhukster commented 6 years ago

Ugg... Have you tried sending test messages with your form? Getting any visible errors?

alfre22 commented 6 years ago

Yes, if I check the settings and save the configuration, whether using the admin plugin or FTP access to my hosting, everything works fine in the beginning, but after a few minutes stops working.

If I use mailtrap.io to track, I can read the emails. To check this out, I change this:

enabled: true from: myaccount@gmail.com from_name: 'My Name' to: myaccount@gmail.com to_name: 'My Name' mailer: engine: smtp smtp: server: smtp.mailtrap.io port: 2525 encryption: tls user: mailtrapusername password: mailtrappass sendmail: bin: /usr/sbin/sendmail content_type: text/html debug: false

alfre22 commented 6 years ago

Right now I have mailtrap.io as server and is not working, but I can't find any log with info about what is happening.

rhukster commented 6 years ago

I've hooked in the debug: true option to use a new logs/email.log file that you can inspect for issues. However for Gmail i've also added a new section to the README.txt:

Google Email

A popular option for sending email is to simply use your Google Accounts SMTP server. To set this up you will need to do 2 things first:

  1. Enable IMAP in your Gmail Settings -> Forwarding and POP/IMAP -> IMAP Access
  2. Enable Less secure apps in your user account settings
  3. If you have 2-factor authentication, you will need to create a unique application password to use rather than your personal password

Then configure the Email plugin:

mailer:
  engine: smtp
  smtp:
    server: smtp.gmail.com
    port: 465
    encryption: ssl
    user: 'YOUR_GOOGLE_EMAIL_ADDRESS'
    password: 'YOUR_GOOGLE_PASSWORD'

NOTE: Check your email sending limits: https://support.google.com/a/answer/166852?hl=en

rhukster commented 6 years ago

for mailtrap there's an example in the README.txt also:

mailer:
  engine: smtp
  smtp:
    server: mailtrap.io
    port: 2525
    encryption: none
    user: YOUR_MAILTRAP_INBOX_USER
    password: YOUR_MAILTRAP_INBOX_PASSWORD
rhukster commented 6 years ago

I've added a bunch more example services and options. i've also tested these so i KNOW they work :) https://github.com/getgrav/grav-plugin-email/blob/develop/README.md