This board is the new home for david63's extensions.

All of the extensions hosted here will need to be treated as a new install as there is no migration from the original ones to these, and furthermore, no support will be given to migrating to any of these extensions from previous versions.


Due to the selfishness of certain board members it has become necessary to apply a limit of how many downloads each member can make before making a donation. Once a donation has been made then you will have unlimited downloads.

[3.3.0] Mail to Post

Fully working extensions
User avatar
devspace
Owner
Owner
Posts: 279
Joined: October 2022

[3.3.0] Mail to Post

#1

Post by devspace »

Mail to Post:

Adds a feature to receive posts via an email.

Compatibility:

Image Image

Image

Notes:
  • If you are using any other version of this extension then it must be Disabled /Delete data and the original files deleted before installing this version - you will loose all settings.
  • See additional notes below.
Features:
  • Controlled by a new user/group permission.
  • Users can select which forum their mail messages will be posted in - this can be overridden in ACP.
  • Mail messages can be retrieved either manually or via a Cron job.
  • All actions are written to a log file.
  • Messages can be moderated if required.
  • Option to use a PIN when sending the mail message.
  • Some basic checks for mail "spoofing"
Language(s):
  • en
Version:
  • 3.3.1
Installation:
  • Download the latest release and unzip it.
  • Upload the unzipped files to [board root]/ext/devspace/mailtopost and enable it in the ACP
Configuration:
  • ACP
  • Extensions
  • Mail to post
  • Mail to post options
  • Set required options
  • ACP
  • Permissions
  • Group permissions
  • Select group
  • Advanced permissions
  • Post
  • Can send mail to post
  • UCP
  • Mail to post
  • Set options
Usage:
  • An email address is required for sending the posts to - Gmail does work but can be awkward to set up.
  • It is recommended that a new user group is created with the permission to use this feature into which you can put the users that you want to use it - this makes "troublemakers" easy to remove.
Extension Download:

User avatar
devspace
Owner
Owner
Posts: 279
Joined: October 2022

[3.3.0] Mail to Post

#2

Post by devspace »

Announcements:

User avatar
devspace
Owner
Owner
Posts: 279
Joined: October 2022

[3.3.0] Mail to Post

#3

Post by devspace »

Additional Notes:
  • You should set up a dedicated email address for this extension and not use a personal email account.
  • If the subject of a mail message is the same as a topic title in the same forum then it will, at Admin's discretion, be a reply.
  • If you get an error message from Google saying that it has blocked the app then there is a setting within your Gmail account to override this message.

pugwonk
Donor
Donor
Posts: 8
Joined: February 2023

Re: [3.3.0] Mail to Post

#4

Post by pugwonk »

Many thanks for making this! I run a BB for the Toyota Century... I myself get emails notification from various places about cars for sale, and I'm hoping to write a script to format these and then auto-post them to my BB. This plugin will be a very useful part of that process but (you could see that coming) I can't get it to work. It connects to my mailbox fine but when I click "download all posts" I get a "General Error" screen which says:

Code: Select all

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_ema' at line 1 [1064]

SQL

INSERT INTO (log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_email, user_id) VALUES ('NO_PERM_SET', '', 1677437792, '67.185.139.19', 0, 0, 'M', '', '2')
It also gives me a backtrace and it looks like the exception happens in mailtopost.php line 559. It wasn't entirely clear to me from the docs what username it was going to post under - the email address I'm sending it from is one that is registered on my BB, but I was wondering if perhaps the problem was because user_email was blank in the INSERT statement. Although I would have thought that would trigger something else other than an "error in SQL syntax". And I wasn't quite sure if the NO_PERM_SET part was bad either (I haven't knowingly set any permissions anywhere yet).

Any help appreciated!

User avatar
devspace
Owner
Owner
Posts: 279
Joined: October 2022

Re: [3.3.0] Mail to Post

#5

Post by devspace »

Can you post the full backtrace please

pugwonk
Donor
Donor
Posts: 8
Joined: February 2023

Re: [3.3.0] Mail to Post

#6

Post by pugwonk »

Here it is!

Code: Select all

General Error
SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_ema' at line 1 [1064]

SQL

INSERT INTO (log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_email, user_id) VALUES ('NO_PERM_SET', '', 1677525509, '67.185.139.19', 0, 0, 'M', '', '2')

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 1023
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 202
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 345
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/ext/devspace/mailtopost/core/mailtopost.php
LINE: 559
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/ext/devspace/mailtopost/core/mailtopost.php
LINE: 171
CALL: devspace\mailtopost\core\mailtopost->error_routine()

FILE: [ROOT]/ext/devspace/mailtopost/controller/admin_actions_controller.php
LINE: 242
CALL: devspace\mailtopost\core\mailtopost->process()

FILE: [ROOT]/ext/devspace/mailtopost/acp/acp_mailtopost_module.php
LINE: 43
CALL: devspace\mailtopost\controller\admin_actions_controller->actions()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: devspace\mailtopost\acp\acp_mailtopost_module->main()

FILE: [ROOT]/adm/index.php
LINE: 81
CALL: p_master->load_active()

User avatar
devspace
Owner
Owner
Posts: 279
Joined: October 2022

Re: [3.3.0] Mail to Post

#7

Post by devspace »

That error message is basically saying that you have not set the user permissions - although it should handle it better than that (will look at that later)

pugwonk
Donor
Donor
Posts: 8
Joined: February 2023

Re: [3.3.0] Mail to Post

#8

Post by pugwonk »

Many thanks for taking a look - I gave my user permission to post and it got a bit further! I then got another SQL error on the line:

Code: Select all

INSERT INTO (log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_email, user_id) VALUES ('SPOOF_EMAIL', 'test post', 1677557874, '40.107.237.54', '8', 0, 'M', 'clr@myemail.com', '2')
I fixed this by turning off the spoof detection, but unfortunately then it fell over again with the below... at this point I can't see any odd values in there so I'm not entirely sure what's happened!

Code: Select all

General Error
SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_ema' at line 1 [1064]

SQL

INSERT INTO (log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_email, user_id) VALUES ('SUCCESS', 'test post', 1677558147, '40.107.237.54', '8', '1689', 'M', 'clr@myemail.com', '2')

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 1023
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 202
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 345
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/ext/devspace/mailtopost/core/mailtopost.php
LINE: 559
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/ext/devspace/mailtopost/core/mailtopost.php
LINE: 528
CALL: devspace\mailtopost\core\mailtopost->error_routine()

FILE: [ROOT]/ext/devspace/mailtopost/controller/admin_actions_controller.php
LINE: 242
CALL: devspace\mailtopost\core\mailtopost->process()

FILE: [ROOT]/ext/devspace/mailtopost/acp/acp_mailtopost_module.php
LINE: 43
CALL: devspace\mailtopost\controller\admin_actions_controller->actions()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: devspace\mailtopost\acp\acp_mailtopost_module->main()

FILE: [ROOT]/adm/index.php
LINE: 81
CALL: p_master->load_active()

pugwonk
Donor
Donor
Posts: 8
Joined: February 2023

Re: [3.3.0] Mail to Post

#9

Post by pugwonk »

Just an addendum to this - it turns out that it was actually managing to create the posts, despite the error. I've set it up on a cron job and it seems to be working great. Thanks for the help!

pugwonk
Donor
Donor
Posts: 8
Joined: February 2023

Re: [3.3.0] Mail to Post

#10

Post by pugwonk »

Me again - it turns out that it wasn't exactly working quite as I expected because it was always posting the first email and then crashing. But I think that'll work fine for my purposes.

I've been struggling a bit to set up the cron job - I am 99% sure that I got it to run once with cron, but it's never run subsequently to that. My cron timer is set to 5 minutes but if I look in the post options, the "next cron run" is set to "Sun Feb 26, 2023 6:38 pm". This was a couple of days ago. I thought maybe resetting the cron timer to zero and then putting it back to 5 might fix it, but sadly it didn't. :(

Chris

User avatar
devspace
Owner
Owner
Posts: 279
Joined: October 2022

Re: [3.3.0] Mail to Post

#11

Post by devspace »

I have found a couple of bugs in this and I will release an updated version probably tomorrow - just need to check a few things first.

As for the cron jobs you do realise that phpBB cron relies on the board being accessed in order to initiate the job and even then it will only run the next job in the queue (there are a number of maintenance cron jobs built into phpBB) - so if you have a quiet board it can take some time for this job to run.

pugwonk
Donor
Donor
Posts: 8
Joined: February 2023

Re: [3.3.0] Mail to Post

#12

Post by pugwonk »

Thanks for looking at this! On the cron job front I do realise it will only run when the board is accessed, but it's not run for 24hrs and I suspect it's maybe due to the run date being in the past?

pugwonk
Donor
Donor
Posts: 8
Joined: February 2023

Re: [3.3.0] Mail to Post

#13

Post by pugwonk »

Turns out the cron job is working fine - apologies. I was confused because it's failing to remove the first message from the inbox because of the other crash.

pugwonk
Donor
Donor
Posts: 8
Joined: February 2023

Re: [3.3.0] Mail to Post

#14

Post by pugwonk »

Hi there - just wondering if you'd managed to finish off the update... I think I've written most of the rest of what I need for automating posting but this is the last piece of my puzzle!

dbraux
Member
Member
Posts: 4
Joined: April 2023

Re: [3.3.0] Mail to Post

#15

Post by dbraux »

Hi,

I installed the extension and it's ok with the mailbox access.

When I try to process a message, I get this error, may be someone has a solution ?

Denis

Code: Select all

SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_...' at line 1 [1064]

SQL

INSERT INTO (log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_email, user_id) VALUES ('NO_EMAIL', '=?UTF-8?B?QWxlcnRlIGRlIHPDqWN1cml0w6k=?=', 1682457101, '209.85.220.73', 0, 0, 'M', 'no-reply@accounts.google.com', '2')

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

FILE: [ROOT]/phpbb/db/driver/driver.php
LINE: 1023
CALL: trigger_error()

FILE: [ROOT]/phpbb/db/driver/mysqli.php
LINE: 202
CALL: phpbb\db\driver\driver->sql_error()

FILE: [ROOT]/phpbb/db/driver/factory.php
LINE: 345
CALL: phpbb\db\driver\mysqli->sql_query()

FILE: [ROOT]/ext/devspace/mailtopost/core/mailtopost.php
LINE: 559
CALL: phpbb\db\driver\factory->sql_query()

FILE: [ROOT]/ext/devspace/mailtopost/core/mailtopost.php
LINE: 278
CALL: devspace\mailtopost\core\mailtopost->error_routine()

FILE: [ROOT]/ext/devspace/mailtopost/controller/admin_actions_controller.php
LINE: 242
CALL: devspace\mailtopost\core\mailtopost->process()

FILE: [ROOT]/ext/devspace/mailtopost/acp/acp_mailtopost_module.php
LINE: 43
CALL: devspace\mailtopost\controller\admin_actions_controller->actions()

FILE: [ROOT]/includes/functions_module.php
LINE: 676
CALL: devspace\mailtopost\acp\acp_mailtopost_module->main()

FILE: [ROOT]/adm/index.php
LINE: 81
CALL: p_master->load_active()

User avatar
devspace
Owner
Owner
Posts: 279
Joined: October 2022

Re: [3.3.0] Mail to Post

#16

Post by devspace »

That looks to me as if you have not configured the extension for the user - have you set permissions?

dbraux
Member
Member
Posts: 4
Joined: April 2023

Re: [3.3.0] Mail to Post

#17

Post by dbraux »

devspace wrote: 26 Apr 2023, 08:42
That looks to me as if you have not configured the extension for the user - have you set permissions?
Thank you for your answer.

I had configured the profile only for the mail recipient user, not for the originator. The error message has disappeared.

I understand that
- user 1 send a mail to user 2
- the cron get's the message in user 2 mailbox and creates a post belonging to user 1 (originator of the massage) with appropriate permission (mail to post)
- I also set the same permission to user 2

Is it correct ?

But I do not see any new message in the forum and no error message.

What can I do further ?

Denis

dbraux
Member
Member
Posts: 4
Joined: April 2023

Re: [3.3.0] Mail to Post

#18

Post by dbraux »

In fact I've still an error message,

Denis

Code: Select all

Erreur générale
SQL ERROR [ mysqli ]

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_...' at line 1 [1064]

SQL

INSERT INTO (log_status, log_subject, log_time, mail_ip, mtp_forum, topic_id, type, user_email, user_id) VALUES ('SUCCESS', 'test mailtopost', 1682529901, '209.85.220.41', '34', '114', 'M', 'denis.braux@gmail.com', '2')

BACKTRACE

FILE: (not given by php)
LINE: (not given by php)
CALL: msg_handler()

dbraux
Member
Member
Posts: 4
Joined: April 2023

Re: [3.3.0] Mail to Post

#19

Post by dbraux »

It seems to work now, except the cron.

I didn't change anything else.

Denis