getgrav / grav-plugin-email

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

Grav Email Plugin and SMTP for Zoho Mail problem #77

Closed gaasen closed 6 years ago

gaasen commented 6 years ago

I use Zoho mail as an external mail solution for my domain.

Everything worked great as long as I used the PHP mail option to forward contact forms to a domain emailaddress.

After the removal of PHP mail from this plugin, my contact forms failed, and I therefore tried to configure SMTP.

I don't have Sendmail on my server, so the SMTP option looked like the only option for me, and should be straight forward, right?

However, no matter how I configure this, Zoho rejects the connection, both with SSL and TLS encryption for the SMTP. I do believe that this fails since this plugin use the email address received in the contactform as the sender of the mail and hence as the login email address.

I have setup a dedicated email address within Zoho, and have tried to use the credentials for this email address to connect to Zoho. (e.g. contactform@mydomain.com). The SMTP settings within the plugin should be correct for that email address.

If I however fill in a contactform with the sender email address test@gmail.com, then I get the following error:

Swift_TransportException (553) Expected response code 250 but got code "553", with message "553 Relaying disallowed as test@gmail.com "

Am I correct at believing that Zoho reject this connection as this plugin are trying to use test@gmail.com as the sender? (and not contactform@mydomain.com).

I do believe the Email plugin is configured this way as it is of course handy to receive a contactform request form a customer, and then be able to simply hit reply within your email solution, and then reply to the person that filled in the form. (and not reply to my contactform@mydomain.com email address.)

After Googling the errorcodes I found a lot of people with the same problem wrt. Zoho, but no clear solution.

Any ideas?

gaasen commented 6 years ago

No replies to this post, so I have resorted to reinstalling an older version of the email plugin which have the PHP mail option still intact. (V2.6.0)

It indeed looks to me like the Grav Email plugin spoofing the sender email address to be the email address of the person filling in the form, is causing the problem.

I do suggest however that the senders address should be configurable (within the plugin) to be either: 1) The email address of the one filling in the form 2) The email address as configured within the Email plugin.

If the email plugin had an option for such configuration, then one could simply use "option 2" when using Zoho or any other email servers that rejected connections as stated above.

rhukster commented 6 years ago

Sorry, missed this one. Did you try with the CLI command and explicitly provide a 'from' address that ZOHO expects?

I also have had ZOHO email issues with a personal account I had related to folders and routing. As a result, I don't have it anymore to test with.

gaasen commented 6 years ago

I am not much of a programmer, so have only tried configuraiton of the Email plugin. How do I try the CLI?

Can this be done through config of the email plugin? Reg. Gøran

rhukster commented 6 years ago

Check the readme.md in this plugin. Did you mean to close?

gaasen commented 6 years ago

Sorry, my fault. Didn't mean to close this

gaasen commented 6 years ago

Hi again, I had a look at it, but as I am no programmer I was not able to make much sense out of it. also, I use the Email plugin in conjunction with the reCaptcha Contact Plugin, so I am not sure how they work together, and where to amend the code.

Finally, if I were to change the code of one or both of these plugins I guess my changes might have been wiped everytime there was an upgrade to these.

In my quest, I guess I had hoped that there could be a simple configuration item within a plugin where I could choose if the sender should be the SMTP address, or the senders email address as submitted in the form.

As such configuration item does not exist, I today managed to get around this "problem" in a different and for me easier way.

1) MX is as I mentioned earlier set to Zoho. 2) I today however setup a dummy email address in my hosting cPanel, and use this email for submitting these forms. 3) I am now able to use the SMTP mailengine and use my "dummy" emailaddress setup on my hostingserver to send the messages received through the contactform to the correct recipients. 4) I have tested this on a couple of GRAV sites on different servers, and that work for me.

I would have preferred that configuration option within the Email plugin though as that would have been a much "cleaner" solution for myself. (And I am sure many other GRAV /Zoho users will face the same problem going forward)

Anyway, thanks a lot for taking your time.

Reg. Gøran

rhukster commented 6 years ago

Just to confirm, i created a new ZOHO account and tried SMTP again. This time I had less issues as soon as I used a valid "ZOHO" user to send the email from:

enabled: true
from:  VALID_ZOHO_USER_ACCOUNT_EMAIL
to: 'testing@test.com'
mailer:
  engine: smtp
  smtp:
    server: smtp.zoho.com
    port: 465
    encryption: ssl
    user: VALID_ZOHO_USER_ACCOUNT_EMAIL
    password: VALID_ZOHO_USER_ACCOUNT_PASSWORD
  sendmail:
    bin: '/usr/sbin/sendmail'

Emails were sent fine via the CLI and also web form.

NOTE: Because ZOHO requires the from: address to be a valid ZOHO user's email address, you must use the reply_to: field in the email settings for the form, to point to the form-submitting-users' email address so the "Reply" button works as expected.