Hi, does anyone have this module working sending emails using an smtp authentication module?

I use https://www.drupal.org/project/smtp site emails working ok, however yaml emails although it says sent it never is actually sent.

Any help greatly appreciated.

Thank You.

Development Notes

  • Branch Name: 2770071-smtp-authentication
  • Commit message: Issue #2770071: Compatibility with SMTP authentication

Comments

NYSolutions.com created an issue. See original summary.

jrockowitz’s picture

StatusFileSize
new35.8 KB

I am pretty sure that webforms has a solution and it just needs to be ported to this module.

Webform setings

jrockowitz’s picture

Issue summary: View changes

  • jrockowitz committed d1f30e6 on 2770071-smtp-authentication
    Issue #2770071: Compatibility with SMTP authentication
    
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new10.16 KB

Okay here is a patch without any tests.

To use short form (Windows friendly) from email addresses you need to...

  • Go to Admin setting (/admin/structure/yamlform/settings)
  • Open EMAIL DEFAULT SETTINGS
  • Check ' Short format:' in 'Email address format'
  • Click Save

@NYSolutions.com Please see if this fixes your problem.

NYSolutions.com’s picture

Thank you for your quick work.
I applied the patch, changed the setting however it is still not working.

  • jrockowitz committed 65d75d0 on 2770071-smtp-authentication-02
    Issue #2770071: Compatibility with SMTP authentication.
    
jrockowitz’s picture

So I am pretty sure the issue was that the YAML form module is attempting to provide support for sending HTML emails and this was blocking the SMTP module from handling emails send by the YAML form module.

Please test the attached patch. You can use the Status Report (/admin/reports/status) to confirm that the SMTP module is now handling sending out the YAML form module's emails.

NYSolutions.com’s picture

Is there a new setting for email provider somewhere.

Status showing YAML form email: HTML support Provided by the YAML Form module

  • jrockowitz committed c9de166 on 2770071-smtp-authentication-02
    Issue #2770071: Compatibility with SMTP authentication. Add update hook.
    
jrockowitz’s picture

StatusFileSize
new14.79 KB

It is probably because you have the SMTP module and YAML form module already enabled.

The attached patch includes an update hook that should address this. If not, please try reinstalling the SMTP module.

NYSolutions.com’s picture

StatusFileSize
new5.56 KB

Sorry I must be doing something wrong, this last patch does not seem to be applying, I am really new at applying patches.

Attached is log of install of all 3 patches. the 1st 2 went smoothly, however the last one shows errors.

AsadKamil’s picture

Hi all, this patch compatibility_with_smtp-2770071-10.patch is successfully applied to 8.x-1.x branch.
Thanks
jrockowitz’s picture

@nysolutions Another approach is to checkout the feature branch.

https://www.drupal.org/node/2640714/git-instructions/2770071-smtp-authen...

NYSolutions.com’s picture

I completely uninstalled the module and reinstalled from the feature branch. I reinstalled the smtp module.
Email still not working.
Status report no longer showing the line about email only yaml reference now is YAML form: CodeMirror (CDN)

jrockowitz’s picture

StatusFileSize
new465.25 KB

The patch is not being applied correctly. Try the attached zip.

NYSolutions.com’s picture

StatusFileSize
new8.91 KB

I got back the yaml info on the status page, however email still showing provided by yaml and not working for me.

status

jrockowitz’s picture

@AsadKamil Can you please test this patch using clean installation. You don't have to even configure the SMTP module. The key thing is the status message should say SMTP when both the YAML form and SMTP module is installed.

  • jrockowitz committed e62ae1e on 2770071-smtp-authentication-02
    Issue #2770071: Compatibility with SMTP authentication.
    
jrockowitz’s picture

Using simplytest.me I was able to get the2770071-smtp-authentication-02 branch installed with the SMTP module and confirm that the status message has been updated.

Here the simplytest.me site, which is only available for 24 hours.

https://rrlrn.ply.st/admin/reports/status

NYSolutions.com’s picture

Wow, completely uninstalled yamlform again and re-downloaded from the2770071-smtp-authentication-02 branch and I can't believe it, it is working now.

jrockowitz’s picture

Status: Needs review » Fixed
kclarkson’s picture

Just tried downloading the newest stable version of smtp - June 27th.

Sending a test message was fine. But once I tried submitting the message in the form I receive the following error.

Here is the error I am receiving -
Invalid address: You must provide at least one recipient email address. Invalid address: The website encountered an unexpected error. Please try again later.
RuntimeException: Failed to start the session because headers have already been sent

NYSolutions.com’s picture

If you go to configuration, SMTP authentication, can you successfully send a test email?

jrockowitz’s picture

I think this issue might not be related to the YAML form. My patch and solution basically allowed the SMTP module to be used to send email. It is possible the YAML form module is sending incorrectly email values/headers to the SMTP module.

Are you able to to duplicate the error using just the Contact form?

kclarkson’s picture

This is the most recent version of core:
-smtp: current stable
-yamlform - 8.x-1.x

Yes I am able to send the test message. Everything looks great with the test and I have also confirmed that the messages are in fact being sent to both the user and the site account.

The only issue now is the error that shows up in the dialogue box after a submission.

Here is the most recent error:

Warning: Invalid argument supplied for foreach() in Drupal\smtp\Plugin\Mail\SMTPMailSystem->mail() (line 404 of modules/smtp/src/Plugin/Mail/SMTPMailSystem.php). Drupal\smtp\Plugin\Mail\SMTPMailSystem->mail(Array) (Line: 227) Drupal\Core\Mail\MailManager->mail('yamlform', 'email.email_confirmation', 'kaleemclarkson@yahoo.com', 'en', Array, 'info@danceitoffstudio.com ') (Line: 507) Drupal\yamlform\Plugin\YamlFormHandler\EmailYamlFormHandler->sendMessage(Array) (Line: 416) Drupal\yamlform\Plugin\YamlFormHandler\EmailYamlFormHandler->postSave(Object, , NULL) (Line: 1248) Drupal\yamlform\Entity\YamlForm->invokeHandlers('postSave', Object, , NULL) (Line: 395) Drupal\yamlform\Entity\YamlFormSubmission->invokeYamlFormHandlers('postSave', ) (Line: 633) Drupal\yamlform\Entity\YamlFormSubmission->postSave(Object, ) (Line: 469) Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 304) Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, ) (Line: 395) Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 747) Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 358) Drupal\Core\Entity\Entity->save() (Line: 663) Drupal\yamlform\Entity\YamlFormSubmission->save() (Line: 737) Drupal\yamlform\YamlFormSubmissionForm->save(Array, Object) call_user_func_array(Array, Array) (Line: 111) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 583) Drupal\Core\Form\FormBuilder->processForm('yamlform_submission_contact_form', Array, Object) (Line: 314) Drupal\Core\Form\FormBuilder->buildForm('yamlform_submission_contact_form', Object) (Line: 48) Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 601) Drupal\yamlform\Entity\YamlForm->getSubmissionForm(Array) (Line: 33) Drupal\yamlform\Plugin\Field\FieldFormatter\YamlFormEntityReferenceEntityFormatter->viewElements(Object, 'en') (Line: 80) Drupal\Core\Field\FormatterBase->view(Object, 'en') (Line: 76) Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view(Object, NULL) (Line: 259) Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 303) Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 24) Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 246) Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 203) Drupal\Core\Entity\EntityViewBuilder->build(Array) call_user_func(Array, Array) (Line: 381) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195) Drupal\Core\Render\Renderer->render(Array, ) (Line: 226) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227) Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117) Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90) Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 144) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628) Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Warning: Invalid argument supplied for foreach() in Drupal\smtp\Plugin\Mail\SMTPMailSystem->mail() (line 404 of modules/smtp/src/Plugin/Mail/SMTPMailSystem.php). Drupal\smtp\Plugin\Mail\SMTPMailSystem->mail(Array) (Line: 227) Drupal\Core\Mail\MailManager->mail('yamlform', 'email.email_notification', 'info@danceitoffstudio.com', 'en', Array, 'kaleemclarkson@yahoo.com ') (Line: 507) Drupal\yamlform\Plugin\YamlFormHandler\EmailYamlFormHandler->sendMessage(Array) (Line: 416) Drupal\yamlform\Plugin\YamlFormHandler\EmailYamlFormHandler->postSave(Object, , NULL) (Line: 1248) Drupal\yamlform\Entity\YamlForm->invokeHandlers('postSave', Object, , NULL) (Line: 395) Drupal\yamlform\Entity\YamlFormSubmission->invokeYamlFormHandlers('postSave', ) (Line: 633) Drupal\yamlform\Entity\YamlFormSubmission->postSave(Object, ) (Line: 469) Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 304) Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, ) (Line: 395) Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 747) Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 358) Drupal\Core\Entity\Entity->save() (Line: 663) Drupal\yamlform\Entity\YamlFormSubmission->save() (Line: 737) Drupal\yamlform\YamlFormSubmissionForm->save(Array, Object) call_user_func_array(Array, Array) (Line: 111) Drupal\Core\Form\FormSubmitter->executeSubmitHandlers(Array, Object) (Line: 51) Drupal\Core\Form\FormSubmitter->doSubmitForm(Array, Object) (Line: 583) Drupal\Core\Form\FormBuilder->processForm('yamlform_submission_contact_form', Array, Object) (Line: 314) Drupal\Core\Form\FormBuilder->buildForm('yamlform_submission_contact_form', Object) (Line: 48) Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 601) Drupal\yamlform\Entity\YamlForm->getSubmissionForm(Array) (Line: 33) Drupal\yamlform\Plugin\Field\FieldFormatter\YamlFormEntityReferenceEntityFormatter->viewElements(Object, 'en') (Line: 80) Drupal\Core\Field\FormatterBase->view(Object, 'en') (Line: 76) Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceFormatterBase->view(Object, NULL) (Line: 259) Drupal\Core\Entity\Entity\EntityViewDisplay->buildMultiple(Array) (Line: 303) Drupal\Core\Entity\EntityViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 24) Drupal\node\NodeViewBuilder->buildComponents(Array, Array, Array, 'full') (Line: 246) Drupal\Core\Entity\EntityViewBuilder->buildMultiple(Array) (Line: 203) Drupal\Core\Entity\EntityViewBuilder->build(Array) call_user_func(Array, Array) (Line: 381) Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195) Drupal\Core\Render\Renderer->render(Array, ) (Line: 226) Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574) Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227) Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117) Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90) Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111) Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 144) Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 62) Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57) Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 98) Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 77) Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47) Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50) Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23) Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 628) Drupal\Core\DrupalKernel->handle(Object) (Line: 19) 
jrockowitz’s picture

> Warning: Invalid argument supplied for foreach() in Drupal\smtp\Plugin\Mail\SMTPMailSystem->mail() (line 404 of modules/smtp/src/Plugin/Mail/SMTPMailSystem.php).

This code is handling file attachments. I am probably passing a bad value to the SMTP module.

Does your form have a file upload?

Can up export your form, remove the emails, and upload it here? Here is video that walks you thru the best way to export a form. https://www.youtube.com/watch?v=ejzx4D0ldl0 Make sure to enable the YAML form devel module.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

kle’s picture

@jrockowitz: such great work !
Ok - I ran in the same problem and figured it out:

In EmailYamlFormHandler::getMessage() line 523ff there is

// Add attachments.
    if ($this->configuration['attachments'] && $this->supportsAttachments()) {
      $message['attachments'] = [];

Please add this

    else {
      $message['attachments'] = [];
    }

otherwise it comes to an error in SMTPMailSystem::mail() in line 438 because $message['params']['attachments'] = FALSE and not an empty array:

// Process mimemail attachments, which are prepared in mimemail_mail().
    if (isset($message['params']['attachments'])) {
      foreach ($message['params']['attachments'] as $attachment) {

Greetings from Cologne

jrockowitz’s picture

Status: Closed (fixed) » Active
jrockowitz’s picture

Status: Active » Needs review
StatusFileSize
new756 bytes

If the attached patch passes all the test, I will just commit it.

jrockowitz’s picture

Status: Needs review » Fixed

Fixed! Please download or checkout the latest dev release.

kle’s picture

Status: Fixed » Closed (fixed)

Thats fast !! - and better than my solution :-)
Maybe its a cache-problem: the patch isnt in latest dev. I grabbed it with "drush dl yamlform --select" and downloaded it as zip. Strange...
Im sure this will work lateron.