0

I have installed the SMTP module, and the test email is working fine and displays no error. I have also installed the webform module through which I am sending emails using an email handler. Whenever i hit rest api {{url}}/webform_rest/submit, i get the following error:

RuntimeException: Failed to start the session because headers have already been sent by ".....\phpmailer\phpmailer\src\SMTP.php" at line 283. in Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage->start() (line 152 of .....\symfony\http-foundation\Session\Storage\NativeSessionStorage.php)

it gives the error because that submission fails toowebfrom-smtp-error

  • Make sure there is absolutely no output to the screen before you try to send email. You can view the source in the browser to see what shows up before that message, then track down where it's coming from. – aynber Aug 22 '22 at 15:05
  • ...just want to point out that it includes spaces, tabs and line breaks. – M. Eriksson Aug 22 '22 at 15:09
  • @aynber sorry i am not getting? I am using restapi through which i am sending data. – Saira Noonari Aug 22 '22 at 15:14
  • @M.Eriksson this is a custom module, i haven't done anything. – Saira Noonari Aug 22 '22 at 15:15
  • That doesn't matter. PHP still works the same, custom drupal module or not. If you get `headers already sent` thrown when trying to start a session, then you do have some output before it. – M. Eriksson Aug 22 '22 at 15:17
  • @M.Eriksson what kind of output? the email and form both are submitted and then this error comes, do you have any solution? – Saira Noonari Aug 22 '22 at 15:32
  • It could be a space/new line before the opening `` in some file that gets loaded before (good reason for omitting the closing PHP tags in PHP-only files). It could be some var_dump, echo, print, print_r, some warning that gets thrown before. _Anything_ that produces some kind of output, basically. – M. Eriksson Aug 22 '22 at 15:35

0 Answers0