Giter Site home page Giter Site logo

grav-plugin-email's Introduction

Grav Email Plugin

The email plugin for Grav adds the ability to send email utilizing the symfony/mailer package. This is particularly useful for the admin and login plugins.

IMPORTANT: Version 4.0 replaced the old deprecated SwiftMailer library with Symfony/Mailer package. This is a modern and well supported library that also has the capability to support 3rd party transport engines such as SendGrid, MailJet, MailGun, MailChimp, etc. This library should be backwards compatible with existing configurations, but please create an issue if you run into any problems.

Installation

The email plugin is easy to install with GPM.

$ bin/gpm install email

Configuration

The plugin uses sendmail binary as the default mail engine.

enabled: true
from:
to:
mailer:
  engine: sendmail
  smtp:
    server: localhost
    port: 25
    encryption: none
    user:
    password:
  sendmail:
    bin: '/usr/sbin/sendmail -bs'
content_type: text/html
debug: false

You can configure the Email plugin by using the Admin plugin, navigating to the Plugins list and choosing Email.

That's the easiest route. Or you can also alter the Plugin configuration by copying the user/plugins/email/email.yaml file into user/config/plugins/email.yaml and make your modifications there.

The first setting you'd likely change is your Email from / Email to names and emails.

Also, you'd likely want to setup a SMTP server instead of using PHP Mail, as the latter is not 100% reliable and you might experience problems with emails.

Built-in Engines

By default Email 4.0 supports 4 native engines:

  • SMTP - Standard "Simple Mail Transport Protocol" - The default for most providers
  • SMTPS - "Simple Mail Transport Protocol Secure" - Not very commonly used
  • Sendmail - Uses the built-in sendmail binary file available on many Linux and Mac systems
  • Native - Uses sendmail_path of php.ini for Mac + Linux, and smtp and smtp_port on Windows

Due to the modular nature of Symfony/Mailer, 3rd party engines are supported via Grav plugins.

3rd-Party Engines Plugin Support

Along with the Email v4.0 release, there has also been several custom provider plugins released to provide support for SMTP, API, and sometimes even HTTPS support for 3rd party providers such as Sendgrid, MailJet, MailGun, Amazon SES, Mailchimp/Mandrill, and others! API or HTTPS will provide a faster email sending experience compared to SMTP which is an older protocol and requires more back-and-forth negotiation and communication compared to the single-request of API or HTTPS solutions.

Examples of the currently available plugins include:

More plugins will be released soon to support Gmail, Mailgun, Mailjet, OhMySMTP, Postmark, and SendInBlue.

SMTP Configurations for popular solutions:

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:

As Gmail no longer supports the "allow less secure apps" option, you now need to have 2FA enabled on the account and setup an "App Password" to create a specific password rather than your general account password. Follow these instructions: https://support.google.com/accounts/answer/185833

Then configure the Email plugin:

mailer:
  engine: smtp
  smtp:
    server: smtp.gmail.com
    port: 587
    user: 'YOUR_GOOGLE_EMAIL_ADDRESS'
    password: 'YOUR_GOOGLE_PASSWORD'

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

Mailtrap.io

A good way to test emails is to use a SMTP server service that's built for testing emails, for example https://mailtrap.io

Setup the Email plugin to use that SMTP server with the fake inbox data. For example enter this configuration in user/config/plugins/email.yaml or through the Admin panel:

mailer:
  engine: smtp
  smtp:
    server: smtp.mailtrap.io
    port: 2525
    encryption: none
    user: YOUR_MAILTRAP_INBOX_USER
    password: YOUR_MAILTRAP_INBOX_PASSWORD

That service will intercept emails and show them on their web-based interface instead of sending them for real.

You can try and fine tune the emails there while testing.

Sparkpost

Generous email sending limits even in the free tier, and simple setup, make Sparkpost a great option for email sending. You just need to create an account, then setup a verified sending domain. Sparkpost does a nice job of making this process very easy and undertandable. Then just click on the SMTP Relay option to get your details for the configuration:

mailer:
  engine: smtp
  smtp:
    server: smtp.sparkpostmail.com
    port: 587
    user: 'SMTP_Injection'
    password: 'SEND_EMAIL_API_KEY'

Then try sending a test email...

Sendgrid

Sendgrid offers a very easy-to-setup serivce with 100 emails/day for free. The next level allows you to send 40k/email a day for just $10/month. Configuration is pretty simple, just create an account, then click SMTP integration and click the button to create an API key. The configuration is as follows:

mailer:
  engine: smtp
  smtp:
    server: smtp.sendgrid.net
    port: 587
    user: 'apikey'
    password: 'YOUR_SENDGRID_API_KEY'

Mailgun

Mailgun is a great service that offers 10k/emails per month for free. Setup does require SPIF domain verification so that means you need to add at least a TXT entry in your DNS. This is pretty standard for SMTP sending services and does provide verification for remote email servers and makes your email sending more reliable. The Mailgun site, walks you through this process however, and the verification process is simple and fast.

mailer:
  engine: smtp
  smtp:
    server: smtp.mailgun.org
    port: 587
    user: 'MAILGUN_EMAIL_ADDRESS'
    password: 'MAILGUN_EMAIL_PASSWORD'

Adjust these configurations for your account.

MailJet

Mailjet is another great service that is easy to quickly setup and get started sending email. The free account gives you 200 emails/day or 600 emails/month. Just signup and setup your SPF and DKIM entries for your domain. Then click on the SMTP settings and use those to configure the email plugin:

mailer:
  engine: smtp
  smtp:
    server: in-v3.mailjet.com
    port: 587
    user: 'MAILJUST_USERNAME_API_KEY'
    password: 'MAILJUST_PASSWORD_SECRET_KEY'

ZOHO

ZOHO is a popular solution for hosted email due to it's great 'FREE' tier. It's paid options are also very reasonable and combined with the latest UI updates and outstanding security features, it's a solid email option.

In order to get ZOHO working with Grav, you need to send email via a user account. You can either use your users' password or generate an App Password via your ZOHO account (clicking on your avatar once logged in), then navigating to My Account -> Security -> App Passwords -> Generate. Just enter a unique app name (i.e. Grav Website).

NOTE: The SMTP host required can be found in Settings -> Mail - > Mail Accounts -> POP/IMAP -> SMTP. This will provide the SMTP server for this account (it may not be imap.zoho.com depending on what region you are in)

mailer:
  engine: smtp
  smtp:
    server: smtp.zoho.com
    port: 587
    user: 'ZOHO_EMAIL_ADDRESS'
    password: 'ZOHO_EMAIL_PASSWORD'

Sendmail

Although not as reliable as SMTP not providing as much debug information, sendmail is a simple option as long as your hosting provider is not blocking the default SMTP port 25:

mailer:
  engine: sendmail
  sendmail:
    bin: '/usr/sbin/sendmail -bs'

Simply adjust your binary command line to suite your environment

SMTP Email Services

Solid SMTP options that even provide a FREE tier for low email volumes include:

If you are still unsure why should be using one in the first place, check out this article: https://zapier.com/learn/email-marketing/best-transactional-email-sending-services/

Testing with CLI Command

You can test your email configuration with the following CLI Command:

$ bin/plugin email test-email -t [email protected]

You can also pass in a configuration environment:

$ bin/plugin email test-email -t [email protected] --env=mysite.com

This will use the email configuration you have located in user/mysite.com/config/plugins/email.yaml. Read the docs to find out more about environment-based configuration: https://learn.getgrav.org/advanced/environment-config

Programmatically send emails

Add this code in your plugins:

        $to = '[email protected]';
        $from = '[email protected]';

        $subject = 'Test';
        $content = 'Test';

        $message = $this->grav['Email']->message($subject, $content, 'text/html')
            ->setFrom($from)
            ->setTo($to);

        $sent = $this->grav['Email']->send($message);

Emails sent with Forms

When executing email actions during form processing, action parameters are inherited from the global configuration but may also be overridden on a per-action basis.

title: Custom form

form:
  name: custom_form
  fields:

    # Any fields you'd like to add to the form:
    # Their values may be referenced in email actions via '{{ form.value.FIELDNAME|e }}'

  process:
    email:
      subject: "[Custom form] {{ form.value.name|e }}"
      body: "{% include 'forms/data.txt.twig' %}"
      from: Custom Sender <[email protected]>
      to: Custom Recipient <[email protected]>
      process_markdown: true

Multiple Emails

You can send multiple emails by creating an array of emails under the process: email: option in the form:

title: Custom form

form:
  name: custom_form
  fields:

    # Any fields you'd like to add to the form:
    # Their values may be referenced in email actions via '{{ form.value.FIELDNAME|e }}'

  process:
    email:
      -
        subject: "[Custom Email 1] {{ form.value.name|e }}"
        body: "{% include 'forms/data.txt.twig' %}"
        from: Site Owner <[email protected]>
        to: Recipient 1 <[email protected]>
        template: "email/base.html.twig"
      -
        subject: "[Custom Email 2] {{ form.value.name|e }}"
        body: "{% include 'forms/data.txt.twig' %}"
        from: Site Owner <[email protected]>
        to: Recipient 2 <[email protected]>
        template: "email/base.html.twig"

Templating Emails

You can specify a Twig template for HTML rendering, else Grav will use the default one email/base.html.twig which is included in this plugin. You can also specify a custom template that extends the base, where you can customize the {% block content %} and {% block footer %}. For example:

{% extends 'email/base.html.twig' %}

{% block content %}
<p>
    Greetings {{ form.value.name|e }},
</p>

<p>
    We have received your request for help. Our team will get in touch with you within 3 Business Days.
</p>

<p>
    Regards,
</p>

<p>
    <b>My Company</b>
    <br /><br />
    E - <a href="mailto:[email protected]">[email protected]</a><br />
    M - +1 555-123-4567<br />
    W - <a href="https://mycompany.com">mycompany.com</a>
</p>
{% endblock %}

{% block footer %}
  <p style="text-align: center;">My Company - All Rights Reserved</p>
{% endblock %}

Sending Attachments

You can add file inputs to your form, and send those files via Email. Just add an attachments field and list the file input fields names. You can have multiple file fields, and this will send all the files as attachments. Example:

form:
  name: custom_form
  fields:

    my-file:
      label: 'Add a file'
      type: file
      multiple: false
      destination: user/data/files
      accept:
        - application/pdf
        - application/x-pdf
        - image/png
        - text/plain

  process:

    email:
      body: '{% include "forms/data.html.twig" %}'
      attachments:
        - 'my-file'

Additional action parameters

To have more control over your generated email, you may also use the following additional parameters:

  • reply_to: Set one or more addresses that should be used to reply to the message.
  • cc (Carbon copy): Add one or more addresses to the delivery list. Many email clients will mark email in one's inbox differently depending on whether they are in the To: or Cc: list.
  • bcc (Blind carbon copy): Add one or more addresses to the delivery list that should (usually) not be listed in the message data, remaining invisible to other recipients.

Specifying email addresses

Email-related parameters (from, to, reply_to, ccand bcc) allow different notations for single / multiple values:

Single email address string

name-addr RFC822 Formatted string

to: Joe Bloggs <[email protected]>

Multiple email address strings

or in name-addr format:

to:
  - Joe Bloggs <[email protected]>
  - Jane Doe <[email protected]>
  - Jasper Jesperson <[email protected]>

Simple array format with names

to: [[email protected], Joe Bloggs]

Formatted email address with names

to:
  email: [email protected]
  name: Joe Bloggs

or inline:

to: {email: '[email protected]', name: 'Joe Bloggs'}

Multiple email addresses (with and without names)

to:
  - [[email protected], Joe Bloggs]
  - [[email protected], Jane Doe]
to:
  -
    email: [email protected]
    name: Joe Bloggs
  -
    email: [email protected]
    name: Jane Doe

or inline:

to:
  - {email: '[email protected]', name: 'Joe Bloggs'}
  - {email: '[email protected]', name: 'Jane Doe'}

Multi-part MIME messages

Apart from a simple string, an email body may contain different MIME parts (e.g. HTML body with plain text fallback):

body:
  -
    content_type: 'text/html'
    body: "{% include 'forms/default/data.html.twig' %}"
  -
    content_type: 'text/plain'
    body: "{% include 'forms/default/data.txt.twig' %}"

Troubleshooting

Emails are not sent

Debugging

The first step in determining why emails are not sent is to enable debugging. This can be done via the user/config/email.yaml file or via the plugin settings in the admin. Just enable this and then try sending an email again. Then inspect the logs/email.log file for potential problems.

ISP Port 25 blocking

By default, when sending via PHP or Sendmail the machine running the webserver will attempt to send mail using the SMTP protocol. This uses port 25 which is often blocked by ISPs to protected against spamming. You can determine if this port is blocked by running this command in your temrinal (mac/linux only):

(echo >/dev/tcp/localhost/25) &>/dev/null && echo "TCP port 25 opened" || echo "TCP port 25 closed"

If it's blocked there are ways to configure relays to different ports, but the simplest solution is to use SMTP for mail sending.

Exceptions

If you get an exception when sending email but you cannot see what the error is, you need to enable more verbose exception messages. In the user/config/system.yaml file ensure your have the following configuration:

errors:
  display: 1
  log: true

Configuration Issues

As explained above in the Configuration section, if you're using the default settings, set the Plugin configuration to use a SMTP server. It can be Gmail or another SMTP server you have at your disposal.

This is the first thing to check. The reason is that PHP Mail, the default system used by the Plugin, is not 100% reliable and emails might not arrive.

grav-plugin-email's People

Contributors

bootedweb avatar d2boy avatar daniel-km avatar diazwatson avatar flaviocopes avatar gour avatar grantholle avatar groberts84 avatar hctom avatar hwmaier avatar janklostermann avatar johnmica avatar lufog avatar mahagr avatar matsxm avatar nicohood avatar rhukster avatar ricardo118 avatar shaneparsons avatar stanschus avatar stephan-strate avatar w00fz avatar xaa avatar yehudaclinton avatar z38 avatar zeegin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

grav-plugin-email's Issues

Expected response code 250 but got code "", with message ""

Config:

enabled: true
from: [email protected]
to: [email protected]
mailer:
  engine: smtp
  smtp:
    server: smtp.sendgrid.net
    port: 587
    encryption: tls
    user: 'SiteContactForm'
    password: 'key...'
from_name: Me
to_name: Me
content_type: text/html
debug: false

Strack trace:

 Swift_TransportException
…
/user
/plugins
/email
/vendor
/swiftmailer
/swiftmailer
/lib
/classes
/Swift
/Transport
/AbstractSmtpTransport.php
383
28
Swift_Transport_AbstractSmtpTransport
_assertResponseCode
…
/user
/plugins
/email
/vendor
/swiftmailer
/swiftmailer
/lib
/classes
/Swift
/Transport
/AbstractSmtpTransport.php
281
27
Swift_Transport_AbstractSmtpTransport
executeCommand
…
/user
/plugins
/email
/vendor
/swiftmailer
/swiftmailer
/lib
/classes
/Swift
/Transport
/EsmtpTransport.php
270
26
Swift_Transport_EsmtpTransport
executeCommand
…
/user
/plugins
/email
/vendor
/swiftmailer
/swiftmailer
/lib
/classes
/Swift
/Transport
/Esmtp
/Auth
/LoginAuthenticator.php
46
25
Swift_Transport_Esmtp_Auth_LoginAuthenticator
authenticate
…
/user
/plugins
/email
/vendor
/swiftmailer
/swiftmailer
/lib
/classes
/Swift
/Transport
/Esmtp
/AuthHandler.php
176
24
Swift_Transport_Esmtp_AuthHandler
afterEhlo
…
/user
/plugins
/email
/vendor
/swiftmailer
/swiftmailer
/lib
/classes
/Swift
/Transport
/EsmtpTransport.php
334
23
Swift_Transport_EsmtpTransport
_doHeloCommand
…
/user
/plugins
/email
/vendor
/swiftmailer
/swiftmailer
/lib
/classes
/Swift
/Transport
/AbstractSmtpTransport.php
118
22
Swift_Transport_AbstractSmtpTransport
start
…
/user
/plugins
/email
/vendor
/swiftmailer
/swiftmailer
/lib
/classes
/Swift
/Mailer.php
79
21
Swift_Mailer
send
…
/user
/plugins
/email
/classes
/Email.php
104
20
Grav
\Plugin
\Email
\Email
send
…
/user
/plugins
/email
/email.php
95
19
Grav
\Plugin
\EmailPlugin
onFormProcessed
…
/vendor
/symfony
/event-dispatcher
/EventDispatcher.php
184
18
call_user_func
…
/vendor
/symfony
/event-dispatcher
/EventDispatcher.php
184
17
Symfony
\Component
\EventDispatcher
\EventDispatcher
doDispatch
…
/vendor
/symfony
/event-dispatcher
/EventDispatcher.php
46
16
Symfony
\Component
\EventDispatcher
\EventDispatcher
dispatch
…
/vendor
/rockettheme
/toolbox
/Event
/src
/EventDispatcher.php
23
15
RocketTheme
\Toolbox
\Event
\EventDispatcher
dispatch
…
/system
/src
/Grav
/Common
/Grav.php
288
14
Grav
\Common
\Grav
fireEvent
…
/user
/plugins
/form
/classes
/form.php
615
13
Grav
\Plugin
\Form
post
…
/user
/plugins
/form
/form.php
188
12
Grav
\Plugin
\FormPlugin
onPagesInitialized
…
/vendor
/symfony
/event-dispatcher
/EventDispatcher.php
184
11
call_user_func
…
/vendor
/symfony
/event-dispatcher
/EventDispatcher.php
184
10
Symfony
\Component
\EventDispatcher
\EventDispatcher
doDispatch
…
/vendor
/symfony
/event-dispatcher
/EventDispatcher.php
46
9
Symfony
\Component
\EventDispatcher
\EventDispatcher
dispatch
…
/vendor
/rockettheme
/toolbox
/Event
/src
/EventDispatcher.php
23
8
RocketTheme
\Toolbox
\Event
\EventDispatcher
dispatch
…
/system
/src
/Grav
/Common
/Grav.php
288
7
Grav
\Common
\Grav
fireEvent
…
/system
/src
/Grav
/Common
/Processors
/PagesProcessor.php
24
6
Grav
\Common
\Processors
\PagesProcessor
process
…
/system
/src
/Grav
/Common
/Grav.php
132
5
Grav
\Common
\Grav
Grav
\Common
\{closure}
…
/system
/src
/Grav
/Common
/Grav.php
379
4
Grav
\Common
\Grav
Grav
\Common
\{closure}
…
/system
/src
/Grav
/Common
/Grav.php
355
3
call_user_func_array
…
/system
/src
/Grav
/Common
/Grav.php
355
2
Grav
\Common
\Grav
__call
…
/system
/src
/Grav
/Common
/Grav.php
133
1
Grav
\Common
\Grav
measureTime
…
/system
/src
/Grav
/Common
/Grav.php
133
0
Grav
\Common
\Grav
process

Environment & details:


 GET Data empty 

data | array:3 [▶]
-- | --
__form-name__ | "contact"
__unique_form_id__ | "bkxu1QLjTWJl7XUNmvsi"
form-nonce | "f4d6f99b452e31e12aeae215fbf0ab32"


PATH | "/bin:/usr/bin:/usr/local/bin"
-- | --
HTTP_ACCEPT | "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
HTTP_ACCEPT_ENCODING | "gzip, deflate"
HTTP_ACCEPT_LANGUAGE | "en-US,en;q=0.5"
HTTP_CONNECTION | "keep-alive"
CONTENT_TYPE | "application/x-www-form-urlencoded"
CONTENT_LENGTH | "209"
HTTP_COOKIE | "phpbb3_r7hh6_k=; _ga=GA1.2.416509928.1506928439; phpbb3_r7hh6_u=1; phpbb3_r7hh6_sid=2ff0cbab672749e4e13e703a10a61134; _gid=GA1.2.1920110451.1512502655; grav-site-07cdce8-admin=fpedl634if0e48i2bt017oc0n3; grav-site-07cdce8=t0ovg7v0i1lfsftmcstlld9071; _gat=1"
HTTP_HOST | "digicamcontrol.com"
HTTP_REFERER | "http://digicamcontrol.com/contact"
HTTP_USER_AGENT | "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:57.0) Gecko/20100101 Firefox/57.0"
HTTP_UPGRADE_INSECURE_REQUESTS | "1"
DOCUMENT_ROOT | "/home/digicamc/public_html"
REMOTE_ADDR | "89.149.62.141"
REMOTE_PORT | "57298"
SERVER_ADDR | "176.223.122.150"
SERVER_NAME | "digicamcontrol.com"
SERVER_ADMIN | "[email protected]"
SERVER_PORT | "80"
REQUEST_URI | "/contact"
REDIRECT_URL | "/contact"
REDIRECT_STATUS | "200"
SCRIPT_FILENAME | "/home/digicamc/public_html/index.php"
QUERY_STRING | ""
SCRIPT_URI | "http://digicamcontrol.com/contact"
SCRIPT_URL | "/contact"
SCRIPT_NAME | "/index.php"
SERVER_PROTOCOL | "HTTP/1.1"
SERVER_SOFTWARE | "LiteSpeed"
REQUEST_METHOD | "POST"
X-LSCACHE | "on"
PHP_SELF | "/index.php"
REQUEST_TIME_FLOAT | 1512555306.4373
REQUEST_TIME | 1512555306

Problem with Sendmail when using reCaptcha Contact plugin

Hi there,
When upgrading the Email Plugin to the current version (that have removed the php mail option) I now get an error with the contact form provided through the reCaptcha Contact Plugin.

When submitting a contact form I get the following error:

Swift_TransportException
Unsupported sendmail command flags [/usr/sbin/sendmail]. Must be one of "-bs" or "-t" but can include additional flags.

Any ideas?

e-mail not send.

Hey.
I'm new to GRAV. I have a problem. Do not send letters from the site. I use the contact form. Palgin set up as specified in the documentation. I checked the sending of mail from the server where the site is hosted - everything is sent.
I check the plugin using CLI: bin / plugin email test-email -t [email protected]
I receive an output in the console:

Current Configuration:

array:8 [
  "enabled" => true
  "from" => "[email protected]"
  "from_name" => null
  "to" => "[email protected]"
  "to_name" => null
  "mailer" => array:3 [
    "engine" => "mail"
    "smtp" => array:5 [
      "server" => "localhost"
      "port" => 25
      "encryption" => "none"
      "user" => ""
      "password" => ""
    ]
    "sendmail" => array:1 [
      "bin" => "/usr/sbin/sendmail"
    ]
  ]
  "content_type" => "text/html"
  "debug" => false
]

Message sent successfully!

The message is saved in the user / data / my-niceform folder
But it does not come to my mailbox!
If I send a message, use the server's command line
sendmail -v [email protected]
Then a message appears in my mailbox. Thus, using the contact form, I can not send a message. The same happens if I use a form to render a message with an attached file. The file is not attached and the message is not sent. Here is the file with the form:

title: Связь
action: '@self'
cache_enable: false
form:
    name: my-nice-form
    fields:
        -
            name: name
            label: Имя
            placeholder: 'ваше имя'
            autofocus: 'on'
            autocomplete: 'on'
            type: text
            validate:
                required: true
        -
            name: email
            label: Е-майл
            placeholder: 'ваш е-майл'
            type: text
            validate:
                rule: email
                required: true
        -
            name: phone
            label: Телефон
            placeholder: 'Номер телефона'
            type: text
            validate:
                required: true
        -
            name: message
            label: Сообщение
            size: long
            placeholder: сообщение
            type: textarea
            validate:
                required: true
        -
            name: my-file
            label: 'Добавить файл'
            type: file
            multiple: true
            description: 'Перетащите файлы сюда'
            destination: 'user/data'
    buttons:
        -
            type: submit
            value: Submit
            classes: btn
        -
            type: reset
            value: Reset
            classes: btn
    process:
        -   email:
                from: "{{ form.value.email|e }}"
                to: "{{ config.plugins.email.to }}"
                subject: "Contact by {{ form.value.name|e }}"
                body: "{% include 'forms/data.html.twig' %}"
                attachments: 'my-file'
        -   save:
                fileprefix: feedback-
                dateformat: Ymd-His-u
                extension: txt
                body: '{% include ''forms/data.txt.twig'' %} {{ config.plugins.email.from }} {{ config.plugins.email.my-file }}'
        -   message: 'Thank you for your feedback!'
        -   display: thankyou
    reset: true

Cannot send mail with gmail smtp (timeout)

Hello, I try to send mail with contact form but I receive always a timeout:

xarkam@intranet:/var/www/grav$ sudo bin/plugin email test-email -t [email protected] 

Current Configuration:

array:8 [
  "enabled" => true
  "from" => "[email protected]"
  "from_name" => null
  "to" => "[email protected]"
  "to_name" => null
  "mailer" => array:3 [
    "engine" => "smtp"
    "smtp" => array:5 [
      "server" => "smtp.gmail.com"
      "port" => 465
      "encryption" => "ssl"
      "user" => "[email protected]"
      "password" => "**************"
    ]
    "sendmail" => array:1 [
      "bin" => "/usr/sbin/sendmail"
    ]
  ]
  "content_type" => "text/html"
  "debug" => true
]
                                                                                            
[Swift_TransportException]                                                                             
  Connection could not be established with host smtp.gmail.com [Connection timed out #110]               
  Log data:                                                                                              
  ++ Starting Swift_SmtpTransport                                                                        
  !! Connection could not be established with host smtp.gmail.com [Connection timed out #110] (code: 0)

Can you help me ?

Email plugin 2.6.2
Contact form 2.9.2

Plugin event hook to alter email recipients depending on form values.

I have a form which should be sent to different offices, depending on values within the form. The easiest way to do this without duplicating the existing plugin and hacking it, is adding an event hook before

$message = $this->buildMessage($params, $vars);
and writing a plugin hooking in on that event, altering the parameters. onEmailSend, for example.

Could you add such an event hook? Or is there another way to achieve the functionality?

I need to send two types messages while submitting form

In my form i have one email field.After submitting the form i need to send confirmation mail of mail to that user and need to send the notification message to that particular organization.

For example
organization id : [email protected]
user id : [email protected]

After submission

one mail to [email protected]

thanks for registering.....

another mail to [email protected]

An enquiry has been made by B.

Please suggest a solution for this?

Emails are not getting sent

Hi, I have messaged a few times on gitter but since I didn't get a response there I thought to get in touch with the plugin creators directly.

I have installed the email and form plugin to create a contact form on my website.

Here is my user/config/plugins/email.yaml

enabled: true
from: <myemail>
from_name: Invite Request
to: <myemail>
to_name: <myname>
mailer: 
  engine: smtp
  smtp:
    server: smtp.mailgun.org
    encryption: none
    user: <mailgunusername>
    password: <mailgunpassword>
content_type: text/html
debug: true

And this is my form.md


---
title: Contact Form

form:
    name: signup

    fields:
        - name: name
          label: Name
          placeholder: Enter your name
          autofocus: on
          autocomplete: on
          tabindex: 1
          type: text
          validate:
            required: true

        - name: email
          label: Email
          placeholder: Enter your email address
          type: email
          tabindex: 2
          validate:
            required: true

        - name: message
          label: Message
          placeholder: Enter your message
          type: textarea
          tabindex: 3
          validate:
            required: false

    buttons:
        - type: submit
          value: Submit
          tabindex: 4
        - type: reset
          value: Reset
          tabindex: 5
    process:
        - email:
            subject: "[Invite Request] {{ form.value.name|e }}"
            body: "{% include 'forms/data.html.twig' %}"
            from: "{{ config.plugins.email.from }}"
            to:
              - "{{ config.plugins.email.from }}"
              - "{{ form.value.email }}"
        - message: Thank you for getting in touch!
        - display: thankyou

---

And nothing seems to happen. There are no errors in the console. It's almost as if the plugin doesn't even get recognised.

class Email not found

Hi guys,

after updating to the latest versions (core + plugins) grav stopped (local worked, but not on fortrabbit) with the error "class Email not found" in

/plugins/email/email.php

After re-adding the line

require_once __DIR__ . '/classes/email.php';

like it was in a previous version:

public function onPluginsInitialized()
    {
        require_once __DIR__ . '/classes/email.php';
        require_once __DIR__ . '/vendor/autoload.php';

        $this->email = new Email();

        if ($this->email->enabled()) {
            $this->grav['Email'] = $this->email;
        }
    }

the error was gone.

g-recaptcha is not processed when sending email with form page

Hi guys,

It seems that the g-recaptcha is not picked up when send is pressed.
I keep getting validation error - recaptcha field not field in.

captura de ecran din 2016 05 11 la 21 20 23

unless I am doing something strange :) I seem to be the one that gets interesting issues with no replication ...

Connection could not be established with host

Hi there,

i'm having an issue with sending the emails via smtp.
the mail is working, the server is traceable from the host

the error i get is:

Connection could not be established with host mail.digimapas.cl [ #0]\n
Log data:\n
++ Starting Swift_SmtpTransport\n
!! Connection could not be established with host mail.digimapas.cl [ #0] (code: 0)

my config:

enabled: true
from: [email protected]
from_name:
to: [email protected]
to_name:
mailer:
  engine: smtp
  smtp:
    server: mail.digimapas.cl
    port: 465
    encryption: ssl
    user: ******@digimapas.cl
    password: **
  sendmail:
    bin: /usr/sbin/sendmail
content_type: text/html
debug: true

I tested the config on xampp and debian/nginx. Always the same error.

new release

we need translations in email subjects. can you make a new release?
thank you!!

Google SMTP 2FA: google identify Grav as not secure

Hi,

I'm following all the steps from the readme for 2FA protected gmail account without success.
It always returns me an error and gmail send me security email:

the error header:

screen shot 2017-12-10 at 03 52 12

the error content:

{
  "error": {
    "type": "Swift_TransportException",
    "message": "Expected response code 250 but got code \"535\", with message \"535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8  https:\/\/support.google.com\/mail\/?p=BadCredentials c54sm14163416wra.84 - gsmtp\r\n\"\nLog data:\n++ Starting Swift_SmtpTransport\n<< 220 smtp.gmail.com ESMTP c54sm14163416wra.84 - gsmtp\r\n\n>> EHLO immersion-pictures.dev\r\n\n<< 250-smtp.gmail.com at your service, [82.251.158.9]\r\n250-SIZE 35882577\r\n250-8BITMIME\r\n250-STARTTLS\r\n250-ENHANCEDSTATUSCODES\r\n250-PIPELINING\r\n250-CHUNKING\r\n250 SMTPUTF8\r\n\n>> STARTTLS\r\n\n<< 220 2.0.0 Ready to start TLS\r\n\n>> EHLO immersion-pictures.dev\r\n\n<< 250-smtp.gmail.com at your service, [82.251.158.9]\r\n250-SIZE 35882577\r\n250-8BITMIME\r\n250-AUTH LOGIN PLAIN XOAUTH2 PLAIN-CLIENTTOKEN OAUTHBEARER XOAUTH\r\n250-ENHANCEDSTATUSCODES\r\n250-PIPELINING\r\n250-CHUNKING\r\n250 SMTPUTF8\r\n\n>> AUTH LOGIN\r\n\n<< 334 VXNlcm5hbWU6\r\n\n>> amltQGltbWVyc2lvbi1waWN0dXJlcy5jb20=\r\n\n<< 334 UGFzc3dvcmQ6\r\n\n>> Y3Bic29hb3J3dWt2ZnBlZQ==\r\n\n<< 534-5.7.14 <https:\/\/accounts.google.com\/signin\/continue?sarp=1&scc=1&plt=AKgnsbt2\r\n534-5.7.14 AbIHDC-sRD4_atsdRKjm_o_nmzyMVn9rLQmB62EYrLwD7YMUSUK7SrH8H2d_yB2mW3tIWZ\r\n534-5.7.14 wHZyMhIN7k8bfZfk-IqBP3HL_8GOaWANCVZR6o7vslD_Onr-h5K2WgdKml4Bsna8SPkzeY\r\n534-5.7.14 UFL_HFmiriG2UeH4zyy7O3DJFyGjS0ukWflgMbCK-MuDkQBB7yPffytGzq2N1cW7CoTpmx\r\n534-5.7.14 vn_5s70_gOQYScB9gWp9DWJAXGkq4> Please log in via your web browser and\r\n534-5.7.14 then try again.\r\n534-5.7.14  Learn more at\r\n534 5.7.14  https:\/\/support.google.com\/mail\/answer\/78754 c54sm14163416wra.84 - gsmtp\r\n\n!! Expected response code 235 but got code \"534\", with message \"534-5.7.14 <https:\/\/accounts.google.com\/signin\/continue?sarp=1&scc=1&plt=AKgnsbt2\r\n534-5.7.14 AbIHDC-sRD4_atsdRKjm_o_nmzyMVn9rLQmB62EYrLwD7YMUSUK7SrH8H2d_yB2mW3tIWZ\r\n534-5.7.14 wHZyMhIN7k8bfZfk-IqBP3HL_8GOaWANCVZR6o7vslD_Onr-h5K2WgdKml4Bsna8SPkzeY\r\n534-5.7.14 UFL_HFmiriG2UeH4zyy7O3DJFyGjS0ukWflgMbCK-MuDkQBB7yPffytGzq2N1cW7CoTpmx\r\n534-5.7.14 vn_5s70_gOQYScB9gWp9DWJAXGkq4> Please log in via your web browser and\r\n534-5.7.14 then try again.\r\n534-5.7.14  Learn more at\r\n534 5.7.14  https:\/\/support.google.com\/mail\/answer\/78754 c54sm14163416wra.84 - gsmtp\r\n\" (code: 534)\n>> RSET\r\n\n<< 250 2.1.5 Flushed c54sm14163416wra.84 - gsmtp\r\n\n>> AUTH PLAIN amltQGltbWVyc2lvbi1waWN0dXJlcy5jb20AamltQGltbWVyc2lvbi1waWN0dXJlcy5jb20AY3Bic29hb3J3dWt2ZnBlZQ==\r\n\n<< 534-5.7.14 <https:\/\/accounts.google.com\/signin\/continue?sarp=1&scc=1&plt=AKgnsbtb\r\n534-5.7.14 8P4LV7wcP7-hqF1BItOiDUUluYJ9qCOvNIJ3JESV8sYU6a2gBarFEhH0kN3PijdGbTlmqA\r\n534-5.7.14 JwZ-8AFW2GU4AZy_CvmDyTE11VYI3hvC5-LuqM4M2NEAF0Ez-r7FxKyIcqndttD5phIVML\r\n534-5.7.14 39_YVoiuztI7NSq4HkMRemPHzkGsD4RVHh95t8GG5HDleJ_3u8gy2iGdk2tcoq9KmmPOCW\r\n534-5.7.14 qTaVY-ppUe0WRwhCXqF_8veICbR3g> Please log in via your web browser and\r\n534-5.7.14 then try again.\r\n534-5.7.14  Learn more at\r\n534 5.7.14  https:\/\/support.google.com\/mail\/answer\/78754 c54sm14163416wra.84 - gsmtp\r\n\n!! Expected response code 235 but got code \"534\", with message \"534-5.7.14 <https:\/\/accounts.google.com\/signin\/continue?sarp=1&scc=1&plt=AKgnsbtb\r\n534-5.7.14 8P4LV7wcP7-hqF1BItOiDUUluYJ9qCOvNIJ3JESV8sYU6a2gBarFEhH0kN3PijdGbTlmqA\r\n534-5.7.14 JwZ-8AFW2GU4AZy_CvmDyTE11VYI3hvC5-LuqM4M2NEAF0Ez-r7FxKyIcqndttD5phIVML\r\n534-5.7.14 39_YVoiuztI7NSq4HkMRemPHzkGsD4RVHh95t8GG5HDleJ_3u8gy2iGdk2tcoq9KmmPOCW\r\n534-5.7.14 qTaVY-ppUe0WRwhCXqF_8veICbR3g> Please log in via your web browser and\r\n534-5.7.14 then try again.\r\n534-5.7.14  Learn more at\r\n534 5.7.14  https:\/\/support.google.com\/mail\/answer\/78754 c54sm14163416wra.84 - gsmtp\r\n\" (code: 534)\n>> RSET\r\n\n<< 250 2.1.5 Flushed c54sm14163416wra.84 - gsmtp\r\n\n>> AUTH XOAUTH2 dXNlcj1qaW1AaW1tZXJzaW9uLXBpY3R1cmVzLmNvbQFhdXRoPUJlYXJlciBjcGJzb2Fvcnd1a3ZmcGVlAQE=\r\n\n<< 334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==\r\n\n!! Expected response code 235 but got code \"334\", with message \"334 eyJzdGF0dXMiOiI0MDAiLCJzY2hlbWVzIjoiQmVhcmVyIiwic2NvcGUiOiJodHRwczovL21haWwuZ29vZ2xlLmNvbS8ifQ==\r\n\" (code: 334)\n>> RSET\r\n\n<< 535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8  https:\/\/support.google.com\/mail\/?p=BadCredentials c54sm14163416wra.84 - gsmtp\r\n\n!! Expected response code 250 but got code \"535\", with message \"535-5.7.8 Username and Password not accepted. Learn more at\r\n535 5.7.8  https:\/\/support.google.com\/mail\/?p=BadCredentials c54sm14163416wra.84 - gsmtp\r\n\" (code: 535)",
    "file": "\/Users\/jim\/Sites\/immersion-pictures\/user\/plugins\/email\/vendor\/swiftmailer\/swiftmailer\/lib\/classes\/Swift\/Plugins\/LoggerPlugin.php",
    "line": 140
  }
}

the gmail security email:
sorry it's in french but it's basically saying: "we just blocked a connexion trial to your account from an app with security risk"

screen shot 2017-12-10 at 03 36 22

To be sure my grav configuration was working I've made some test with an other gmail account but without 2FA and by activating less secure apps option. And this time It was working... Mails are properly send!

Of course activating less secure apps is not an option for production for obvious reasons.

If Grav is not consider by Google as secure maybe the best way would be to add an oauth solution for this plugin? (from what I've read on google...)

I hope you have some kind of solution :)

Thank you

Form file upload does not work

Hi guys!
I heve problem with attaching files to email message.
I have configured this fields:

form:
action: /contact
name: contact-form
fields:
…

    name: my-file
    label: 'Add a file'
    type: file
    multiple: false
    destination: user/data/files
    accept:
        - application/pdf
        - application/x-pdf
        - image/png
        - text/plain
buttons:
-
  type: submit
  value: 'Send Message’
  classes: 'btn btn-primary’
  process:
-
  email:
    from: ‘{{ config.plugins.email.from }}‘
    to: [’{{ config.plugins.email.to }}’]
    subject: '[Contact] {{ form.value.name|e }}'
    body: '{% include ‘‘forms/data.html.twig’’ %}'
    content_type: 'text/html’
    charset: 'UTF-8’
    attachments:
        - my-file

But still i receive messages without attachment.
Also ajax upload does not work and it looks like inactive button. I have to uncheck “display: none” in css properties.
Anybody have idea what is a problem?

I am testing this on localhost and also building by heroku on herokuapp.com

Cannot send emails using smtp.gmail.com

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: [email protected]
from_name: 'My Name'
to: [email protected]
to_name: 'My Name'
mailer:
  engine: smtp
  smtp:
    server: smtp.gmail.com
    port: 587
    encryption: tls
    user: [email protected]
    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!

password stored in open text

Loaded gravstrap skeleton. updated everything. running on ubuntu.
enabled email plugin and provided configuration data.
Just looked at user/config/plugins/email.yaml and see that the password is in open text, next to the fieldname password.
This does not seem to me to be a secure practice. An intruder obtaining entry to a site would surely grep for lines with password.
Further: if debug option is on in Grav, then the plugins tab pulls out all the yaml config information, including the password.
Are there no other configuration options you could use to mask the password?

email plugin not sending email with error #110

Hi,

I'm trying to use the plugin to send a test email to my mailtrap inbox. here is the config I enter in the admin panel:

Mail Engine: SMTP
SMTP server: smtp.mailtrap.io
Port: 465
encryption: None
login: 9e05ad03b3faa5 (I'm sure it is the right login)
password: xxxxxxxxxxx (I'm sure it is the right password)
debug enabled

here is the error I get:

0 - Connection could not be established with host smtp.mailtrap.io [Connection timed out #110] Log data: ++ Starting Swift_SmtpTransport !! Connection could not be established with host smtp.mailtrap.io [Connection timed out #110] (code: 0)

I am running on funio.com webhost
Any help will be appreciated. Thanks!

Smtp password visible

When inputting the Smtp password, I noticed that it doesn't hide it. Is this by design?
It doesn't feel all that safe to just have it in the open.

Engine 'mail' regression since release 2.7.0

As I could see in the readme, engine 'mail' has been deprecated and it results in a regression for me since release 2.7.0. I retrieved a backup of the 2.6.2 release and it works well.
The other two methods don't work for me. Only the engine 'mail' is working in my case.
SMTP won't work since my provider is blocking the ports. While sendmail works from SSH, it does not work either from the plugin.
Please integrate the engine 'mail' again or I'm stuck with version 2.6.2.

email plugin doesn´t work with ssl / tls

When I test the plugin with mailtrap.io everything works fine.
The configuration in user/config/plugin/email.yaml ist as follows:

enabled: true
from: [email protected]
to: [email protected]
mailer:
  engine: smtp
  smtp:
    server: mailtrap.io
    port: 2525
   # encryption: 
    user: 123546
    password:   12345
  sendmail:
    bin: /usr/sbin/sendmail
content_type: text/html
debug: true

When I change the configuration to:

enabled: true
from: [email protected]
to: [email protected]
mailer:
  engine: smtp
  smtp:
    server: smtp.1und1.de
    port: 465
    encryption: ssl
    user: [email protected]
    password: abcdefg
  sendmail:
    bin: /usr/sbin/sendmail
content_type: text/html
debug: true

I get the following error:
0 - Connection could not be established with host smtp.1und1.de [Connection timed out #110] Log data: ++ Starting Swift_SmtpTransport !! Connection could not be established with host smtp.1und1.de [Connection timed out #110](code: 0)

I tested all combinations of ports and encryptions and also with gmail smtp-server. Any help is appreciated.

No $params being send to email.php?

I have a form configured to send email via SMTP:

my email.yaml:

enabled: true
from: [email protected]
from_name: Bob Rockefeller
mailer:
  engine: smtp
  smtp:
    server: minutemen.reclaimhosting.com
    port: 465
    encryption: SSL
    user: 'XXXXX'
    password: 'XXXXX'
  sendmail:
    bin: '/usr/sbin/sendmail'
content_type: text/html
debug: false

My form blueprint:

form:
  name: contact-form
  method: POST

  fields:
    - name: name
      label: Name:
      autofocus: on
      autocomplete: on
      type: text
      validate:
        required: true
      outerclasses: contact-form-name

    - name: email
      label: Email:
      type: email
      validate:
        required: true
      outerclasses: contact-form-email

    - name: message
      label: Message:
      type: textarea
      validate:
        required: true
      outerclasses: contact-form-body
      
    - name: honeypot
      type: honeypot
      
  buttons:
    - type: submit
      value: Submit
      classes: contact-form-button
    - type: reset
      value: Reset
      classes: contact-form-button
      
  process:
    - email:
      subject: Contact from BR.com
      to: [email protected]
      to_name: Bob Rockefeller
      from: "{{form.value.email|e}}"
      from_name: "{{form.value.name|e}}"
      body: "{{form.value.message|e}}"

When the form processes and attempts to send the email, I get this error:

Server Error
Sorry, something went terribly wrong!

0 - Argument 1 passed to Grav\Plugin\EmailPlugin::buildMessage() must be of the type array, null given, called in /Users/bob/Dropbox/SyncedSites/vhosts/www.br.dev/user/plugins/email/email.php on line 74

So I have something screwed up somewhere. But what?

could you precise how to 'make your modifications'

For instance, what are the possiblities about encryption (TLS?)
I mean: 'if I put my password there with no encryption then my password is send without protection?'
for server: localhost
this is a example when site is underconstruction?
Sorry not to be able to understand... Best regards...

Asking, which's faster

I see that there's some option to sent mail, but for me now it's only working through the smtp. Nah the thing that I wanted to ask, which's faster from 3 option available for grav? SMTP, PhpMail or SendMail?

Nginx hangs when submitting contact form

I'm getting a 503 gateway timeout, but the mail sends correctly. My guess is that my vps is a bit slow with sending mail over smtp and Grav waits for it to succeed before showing the 'Thank you' message. Is there any way to stop CeeVee from waiting until the email is sent?

File attachment error given by swift mailer

Hey I don´t know how I can create a pull request for that but here ist my correction for the attachment thing. It is working so far.

if (isset($params['attachments'])) {
    $filesToAttach = (array)$params['attachments'];
    if ($filesToAttach) foreach ($filesToAttach as $fileToAttach) {
        $filesValues = $form->value($fileToAttach);
        if ($filesValues) foreach($filesValues as $filename) { <-- change to filename cause of string is given
            // $filename = $fileValue[0]; <-- no need of it
            $message->attach(\Swift_Attachment::fromPath($filename));
        }
    }
}

but there is some more errors yet. The swift mailer cant find the file, cause the temp file path/name is not given by the process handler. I don´t understand the core of GRAV that much so I can find how to fix that. But I think there is something missing in. Swift is creating this error message:

Whoops\Exception\ErrorException thrown with message "fopen(M): failed to open stream: No such file or directory"

Stacktrace:
#28 Whoops\Exception\ErrorException in /Users/marvin/Documents/Projects/Websites/Promediagroup/GRAV/user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php:138
#27 fopen in /Users/marvin/Documents/Projects/Websites/Promediagroup/GRAV/user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php:138
#26 Swift_ByteStream_FileByteStream:_getReadHandle in /Users/marvin/Documents/Projects/Websites/Promediagroup/GRAV/user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php:86
#25 Swift_ByteStream_FileByteStream:read in /Users/marvin/Documents/Projects/Websites/Promediagroup/GRAV/user/plugins/email/vendor/swiftmailer/swiftmailer/lib/classes/Swift/Mime/SimpleMimeEntity.php:707
............

Form notices unreliable

I'm having a problem whereby the form confirmation messages gets shown unreliably. The email gets sent correctly, but the confirmation mostly doesn't show up in my production environment (and mostly does show up in my local dev environment). Sometimes the notice gets stuck no matter what and shows up even if I open an incognito window with the page.

How can I debug this issue?

Need a test button

Can you please add a "Test" button on the configuration page, which causes a simple test email to be sent with the current configuration settings. Any errors generated before the email has been successfully sent to the first mail handler should be displayed.

The button should perform simple sanity checks on the current configuration before attempting to send the email and issue a warning, for example, if SMTP has been selected but there is no SMTP server specified.

To look cool, the button could change to "Save and Test" if there are unsaved changes on the page.

Regards, Glen.

How to implement custom mail function?

I am pretty new to the grav. I like the CMS, it is great.

But one thing I am struggling with is that I need to implement custom mail function. I want to send mails using sparkpost. Is there any way how to implement custom mail engine?

I know the answer will probably be trivial. But I can't find it anywhere...

Encrypted password for SMTP

Hi there!
How can i store a encrypted password for SMTP?

After setting up "Email plugin" in admin panel,
i get "email.yaml" @ server, in ../user/config/plugins
It looks like this:

enabled: true
from: [email protected]
to: [email protected]
mailer:
  engine: smtp
  smtp:
    server: smtp.example.com
    port: 465
    encryption: ssl
    user: nick1
    password: '12345'
  sendmail:
    bin: /usr/sbin/sendmail
content_type: text/html
debug: false

Where the password is stored unencrypted.
And any user having access to the server can see the public mail password.

Sendmail issue

I use the plugin subscribe and since the last update, i get (the plugin subscribe was not updated since a while, but this one was updated):

Swift_TransportException
Unsupported sendmail command flags [/usr/sbin/sendmail]. Must be one of "-bs" or "-t" but can include additional flags.

is it possible to integrate ajax form submission on this plugin?

Hi, I am working on a form plugin. Im a newbie with php as well. I was wondering if we can hook an ajax script to avoid refreshing the page that contains contact form.
What I do so far is defined fields on a .md file but to avoid refreshing the page, Im planning on using ajax to send data to process hook.. is this possible?

Thank you

mailer.engine vs. mailer.default

I just stumbled upon the following: In the blueprint there is mailer.engine defined as a hidden field (which of course results in no configuration options). On the other hand, there is mailer.default, which allows configuration, because it is defined as a select field with options for

  • none
  • mail
  • smtp
  • sendmail

In the Email class then the plugins.email.mailer.engine config value is used to initialize the correct mailer (which was introduced in 89274e4).

So now I am really confused if something got messed up here? Perhaps the maintainers can have a look at that or give me advice how this should be solved.

Sending variables or data from Grav template

Nice plugin, but is it possible to send some variables from Grav template? For example, i have simple product request form, but i need to add page path from which page was form sent or some product information, like product name. All data are in the template, but {{ variable }} is not working if used in page header of the MD file.

Ability to change 'process.email.to' dynamically per single page

I have a page collection of events. Each single event page has a contact form. Visually the contact form itself is always the same and defined in the events parent page header.

Then it's displayed in the single pages via include:
{% include "forms/events/form.html.twig" with { form: forms('event-contact-form') } %}

The only thing that needs to be dynamic per event is process.email.to because the contact form data will be send to different people depending on the type of the event. There is a field in the event single template which allows the editors to specify email address where it needs to be sent to. Therefore, setting process.email.to to config.plugins.email.to isn't going to work as it's always static.

What is the best way to achieve this?

Enable STARTTLS

Hey Guys ,

how can i enable STARTTLS for the email plugin in grav.
In the admin dashboard are only SSL and TTL available.

We are using a self signed certificate and i get this error message when i change the encryption to tls in the email.yaml.

:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

Grav Email Plugin and SMTP for Zoho Mail problem

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. [email protected]). 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 [email protected], then I get the following error:

Swift_TransportException (553)
Expected response code 250 but got code "553", with message "553 Relaying disallowed as [email protected] "

Am I correct at believing that Zoho reject this connection as this plugin are trying to use [email protected] as the sender? (and not [email protected]).

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 [email protected] email address.)

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

Any ideas?

How to get checkboxes options labels in email body?

Hi all!

I want to get the checked checkboxes labels in the body object (example: Captation vidéo label), but there is only the name and value in the form fields object, so the message body is like this:

Message body:

Object:
 {"object-captation_video":"captation_video"}

contact.md:

            name: object
            type: checkboxes
            options:
                enregistrement: enregistrement
                mixage: Mixage label
                travaux_d_electronique: Travaux d'électronique label
                captation_video: Captation vidéo label

default/data.html.twig

{% for index, field in form.fields %}
    {% set input = attribute(field, "input@") %}
    {% if input is null or input == true %}
        {% block field %}

             <div>
                  {% block field_label %}
                      <strong>{{ field.label }}</strong>:
                  {% endblock %}
                  {% block field_value %}
                      {{ string(form.value(field.name ?? index))|nl2br }}
                  {% endblock %}
              </div>

        {% endblock %}
    {% endif %}
{% endfor %}

Any ideas to figure out?

Update swiftmailer to 5.4.3

E_WARNING - getmypid() has been disabled for security reasons

Getting this warning right now because 5.4.2 version has this function included. Latest version doesn't have it.

Let's update to 5.4.3 version. Cheers :)

Identifier "base_url" is not defined.

Hi there,

I have problems when setting up the client SMTP. The following is the configuration:

enabled: true
from: [email protected]
to: [email protected]
mailer:
  engine: mail
  smtp:
    server: localhost
    port: 25
    encryption: none
    user: 'test'
    password: 'test'
  sendmail:
    bin: '/usr/sbin/sendmail'
content_type: text/html
debug: true 

The problem rise up when i execute the command:
bin/plugin email test-email -t [email protected] -e cefis.dtdns.net/Boavida

Returning me the below message:

[InvalidArgumentException]
  Identifier "base_url" is not defined.

Could you please help me?
Thanks in advance.

Can't send email via PHP Mail

Hi dear devs.
I've been enjoying grav so much for the past few days, its amazing. Thanks a lot.
But then I tried to configure form emails... Can't get it to send something via PHP Mail and that's my preferable way to do it.

I found out that I could debug using debug: true in email.yaml.
But I haven't found any info on how do I debug. Only that I should use smpt instead of 'unreliable' PHP Mail, which works everytime I tested on the same hosting with the following simple code...

<?php
	error_reporting(0);
	if (isset($_POST["submit"])) {
		$name = $_POST['name'];
		$email = $_POST['email'];
		$message = $_POST['message'];
		$human = intval($_POST['human']);
		$from = $email;
		$to = '[email protected]';
		$subject = 'It was sent from domain.com';

		$body ="From: $name\n E-Mail: $email\n Message:\n $message";
		// Check if name has been entered
		if (!$_POST['name']) {
			$errName = 'Enter your name';
		}

		// Check if email has been entered and is valid
		if (!$_POST['email'] || !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
			$errEmail = 'Enter correct email';
		}

		//Check if message has been entered
		if (!$_POST['message']) {
			$errMessage = 'Enter message';
		}
		//Check if simple anti-bot test is correct
		if ($human !== 14) {
			$errHuman = 'The correct answer is: 14';
		}
// If there are no errors, send the email
if (!$errName && !$errEmail && !$errMessage && !$errHuman) {
	if (mail ($to, $subject, $body, $from)) {
		$result='<div class="alert alert-success">Ty. Will reach to you soon.</div>';
	} else {
		$result='<div class="alert alert-danger">Sorry, there\'s some kind of mistake. Try to reach [email protected] directly.</div>';
	}
}
	}
?>

All I have found about email logs was quite unhelpful logs/grav.log, which got something like this:

[2017-10-26 13:04:49] grav.DEBUG: Email Log:  [] []

Here's my form config.
form.txt
Sending from it saves contents to user/data/contact-form as expected.

Here's my email.yaml.

enabled: true
from:
from_name:
to: [email protected]
to_name: Any Name
mailer:
  engine: mail
  smtp:
    server: localhost
    port: 25
    encryption: none
    user: ''
    password: ''
  sendmail:
    bin: '/usr/sbin/sendmail'
content_type: text/html
debug: false

Can you help me not to reinvent the wheel and making simpler version of your plugin? :(

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.