meeting-room-booking-system / mrbs-code

MRBS application code
Other
124 stars 61 forks source link

rejection email #2757

Open jberanek opened 4 years ago

jberanek commented 4 years ago

Is it the case that users shoulds receive an email when a booking is rejected? Our users are reporting that they get an email to tell them their bookings have been approved, but not when they have been denied. Have done the obvious checking of spam folders etc without any luck. I switched on de-bugging, which produced a report (below). This indicates that mail is being sent - it's just that no-one is receiving it. I notice that line 3 of the debug says that 'backend Mail' is being used and I assume this means the native PHP mail function? However, I have defined an SMTP server in my config.inc.php. and it is defined as active. ($smtp_settings['auth'] = true; ) Maybe I am reading this wrong...

Here's the debug output and thanks for any assistance:

[DEBUG] Preparing email for deleted booking
[DEBUG] Preparing to send email ...
[DEBUG] Using backend 'mail'
[DEBUG] From: name@domain.com
[DEBUG] To:  recipient@domain.com
[DEBUG] Cc: name@domain.com
[DEBUG] Bcc:
[DEBUG] Email sent successfully

E_WARNING in /sitename/MRBS/del_entry.php at line 114
Cannot modify header information - headers already sent by (output started at/sitename/MRBS/functions_mail.inc:1077)
MRBS GET: Array
(
)
MRBS POST: Array
(
    [csrf_token] => 7609ada8585ce17672eba192f31ab817c8539b0bbbaf84a3bc6b86a6d9c22041
    [id] => 85854
    [series] => 0
    [returl] => pending.php
    [action] => reject
    [note] => This is a trial.
)
MRBS SESSION: Array
(
    [csrf_token] => 7609ada8585ce17672eba192f31ab817c8539b0bbbaf84a3bc6b86a6d9c22041
)

Reported by: *anonymous

Original Ticket: mrbs/support-requests/2063

jberanek commented 4 years ago

Have you got the following set?

$mail_settings['on_change'] = true;  // when an entry is changed
$mail_settings['on_delete'] = true;  // when an entry is deleted

To make the system use SMTP you need

$mail_settings['admin_backend'] = 'smtp';

$smtp_settings['auth'] means "use SMTP authentication", not "use SMTP".

Original comment by: campbell-m

jberanek commented 4 years ago

Oh, thanks. Well, I do have the first two settings set to 'true'. I didn't have the 'admin_backend' setting correct, but I changed it and debug says that SMTP was being used. Still no mail, though. I have the SMTP settings correct and I am actually wondering if there is a problem with my ISP as they do occasionally have some servers black-listed for (alleged) spamming. I've switched back to using the 'Mail' function now so as to rule them out of the equation for the time-being. But I am back to square 1 - approval mail is fine, rejection mail just doesn't materialise.

Original comment by: *anonymous

jberanek commented 4 years ago

Can you post your $mail_settings here please (having first removed anything confidential)?

Original comment by: campbell-m

jberanek commented 4 years ago

... I should have mentioned: When I tried using SMTP, the debug info said that the message was refused because of 'Relaying denied' and then said there was an 'invalid recipient'. Don't know if that's of any use?

Original comment by: *anonymous

jberanek commented 4 years ago

Sure - and thanks. Here is the whole lot, copied from config.inc.php

/**********************************************
 * Email settings
 **********************************************/

// WHO TO EMAIL
// ------------
// The following settings determine who should be emailed when a booking is made,
// edited or deleted (though the latter two events depend on the "When" settings below).
// Set to true or false as required
// (Note:  the email addresses for the room and area administrators are set from the
// edit_area_room.php page in MRBS)
$mail_settings['admin_on_bookings']      = false;  // the addresses defined by $mail_settings['recipients'] below
$mail_settings['area_admin_on_bookings'] = true;  // the area administrator
$mail_settings['room_admin_on_bookings'] = true;  // the room administrator
$mail_settings['booker']                 = true;  // the person making the booking
$mail_settings['book_admin_on_approval'] = false;  // the booking administrator when booking approval is enabled
                                                   // (which is the MRBS admin, but this setting allows MRBS
                                                   // to be extended to have separate booking approvers)     

// WHEN TO EMAIL
// -------------
// These settings determine when an email should be sent.
// Set to true or false as required
//
// (Note:  (a) the variables $mail_settings['admin_on_delete'] and
// $mail_settings['admin_all'], which were used in MRBS versions 1.4.5 and
// before are now deprecated.   They are still supported for reasons of backward
// compatibility, but they may be withdrawn in the future.  (b)  the default 
// value of $mail_settings['on_new'] is true for compatibility with MRBS 1.4.5
// and before, where there was no explicit config setting, but mails were always sent
// for new bookings if there was somebody to send them to)

$mail_settings['on_new']    = true;   // when an entry is created
$mail_settings['on_change'] = true;  // when an entry is changed
$mail_settings['on_delete'] = true;  // when an entry is deleted

// It is also possible to allow all users or just admins to choose not to send an
// email when creating or editing a booking.  This can be useful if an inconsequential
// change is being made, or many bookings are being made at the beginning of a term or season.
$mail_settings['allow_no_mail']        = false;
$mail_settings['allow_admins_no_mail'] = true;  // Ignored if 'allow_no_mail' is true
$mail_settings['no_mail_default'] = false; // Default value for the 'no mail' checkbox.  
                                           // true for checked (ie don't send mail),
                                           // false for unchecked (ie do send mail)

// WHAT TO EMAIL
// -------------
// These settings determine what should be included in the email
// Set to true or false as required
$mail_settings['details']   = true; // Set to true if you want full booking details;
                                     // otherwise you just get a link to the entry
$mail_settings['html']      = true; // Set to true if you want HTML mail
$mail_settings['icalendar'] = false; // Set to true to include iCalendar details
                                     // which can be imported into a calendar.  (Note:
                                     // iCalendar details will not be sent for areas
                                     // that use periods as there isn't a mapping between
                                     // periods and time of day, so the calendar would not
                                     // be able to import the booking)

// HOW TO EMAIL - LANGUAGE
// -----------------------------------------

// Set the language used for emails (choose an available lang.* file).
$mail_settings['admin_lang'] = 'en';   // Default is 'en'.

// HOW TO EMAIL - BACKEND
// ----------------------
// Set the name of the backend used to transport your mails. Either 'mail',
// 'smtp', 'sendmail' or 'qmail'. Default is 'mail'.
$mail_settings['admin_backend'] = 'mail';

// HOW TO EMAIL - ADDRESSES
// ------------------------
// The email addresses of the MRBS administrator are set in the config file, and
// those of the room and area administrators are set though the edit_area_room.php
// in MRBS.    But if you have set $mail_settings['booker'] above to true, MRBS will
// need the email addresses of ordinary users.   If you are using the "db" 
// authentication method then MRBS will be able to get them from the users table.  But
// if you are using any other authentication scheme then the following settings allow
// you to specify a domain name that will be appended to the username to produce a
// valid email address (eg "@domain.com").
$mail_settings['domain'] = '';
// If you use $mail_settings['domain'] above and username returned by mrbs contains extra
// strings appended like domain name ('username.domain'), you need to provide
// this extra string here so that it will be removed from the username.
$mail_settings['username_suffix'] = '';

/*******************
 * SMTP settings
 */

// These settings are only used with the "smtp" backend
$smtp_settings['host'] = 'mail3.myhost.co.uk';  // SMTP server
$smtp_settings['port'] = 465;           // SMTP port number
$smtp_settings['auth'] = true;        // Whether to use SMTP authentication
$smtp_settings['secure'] = 'ssl';         // Encryption method: '', 'tls' or 'ssl' - note that 'tls' means TLS is used even if the SMTP
                                       // server doesn't advertise it. Conversely if you specify '' and the server advertises TLS, TLS
                                       // will be used, unless the 'disable_opportunistic_tls' configuration parameter shown below is
                                       // set to true.
$smtp_settings['name@domain.com'] = '';       // Username (if using authentication)
$smtp_settings['password'] = '';       // Password (if using authentication)
$smtp_settings['disable_opportunistic_tls'] = true; // Set this to true to disable
                                                     // opportunistic TLS
                                                     // https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#opportunistic-tls
// If you're having problems with sending email to a TLS-enabled SMTP server *which you trust* you can change the following
// settings, which reduce TLS security.
// See https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting#php-56-certificate-verification-failure
$smtp_settings['ssl_verify_peer'] = true;
$smtp_settings['ssl_verify_peer_name'] = true;
$smtp_settings['ssl_allow_self_signed'] = true;

// EMAIL - MISCELLANEOUS
// ---------------------

// Set the email address of the From field. Default is 'admin_email@your.org'
$mail_settings['from'] = 'name@domain.com';

// The address to be used for the ORGANIZER in an iCalendar event.   Do not make
// this email address the same as the admin email address or the recipients 
// email address because on some mail systems, eg IBM Domino, the iCalendar email
// notification is silently discarded if the organizer's email address is the same 
// as the recipient's.  On other systems you may get a "Meeting not found" message.
$mail_settings['organizer'] = 'name@domain.com';

// Set the recipient email. Default is 'admin_email@your.org'. You can define
// more than one recipient like this "john@doe.com,scott@tiger.com"
$mail_settings['recipients'] = 'name@domain.com';

// Set email address of the Carbon Copy field. Default is ''. You can define
// more than one recipient (see 'recipients')
$mail_settings['cc'] = '';

// Set to true if you want the cc addresses to be appended to the to line.
// (Some email servers are configured not to send emails if the cc or bcc
// fields are set)
$mail_settings['treat_cc_as_to'] = false;

// The filename to be used for iCalendar attachments.   Will always have the
// extension '.ics'
$mail_settings['ics_filename'] = "booking";

// Set this to true if you want MRBS to output debug information when you are sending email.
// If you are not getting emails it can be helpful by telling you (a) whether the mail functions
// are being called in the first place (b) whether there are addresses to send email to and (c)
// the result of the mail sending operation.
$mail_settings['debug'] = true;
// Where to send the debug output.  Can be 'browser' or 'log' (for the error_log)
$mail_settings['debug_output'] = 'browser';

// Set this to true if you do not want any email sent, whatever the rest of the settings.
// This is a global setting that will override anything else.   Useful when testing MRBS.
$mail_settings['disabled'] = false;
?>

Original comment by: *anonymous

jberanek commented 4 years ago

You've got two different problems. (1) Your SMTP server doesn't allow you to use it (2) When you use the mail backend the email isn't getting through.

In your initial post were the addresses the ones you'd expect?

[DEBUG] From: name@domain.com [DEBUG] To: recipient@domain.com [DEBUG] Cc: name@domain.com

If so, I don't know why the email's not appearing.

Original comment by: campbell-m

jberanek commented 4 years ago

Thanks for looking. Just to reiterate - the names you list above are all present and correct. We get notification of new bookings and notification if we delete one but nothing if we deny approval/request more info. I cannot see why. I will try and get the SMTP server operating properly and see if that helps. Many thanks for your assistance - appreciated.

Original comment by: *anonymous

jberanek commented 4 years ago

I'm using the version 1.7.5 and I have the same problem. The error is: ... Sender address rejected: not owned by user ... When I reject a booking, the mail try outgoing with my user and fail with error above. When I aprooved, the mail has sent with mail configured on $mail_settings['from'] .

What I can change to allways send with same mail address?

Original comment by: humbertos

jberanek commented 4 years ago

Straight from systemdefaults.inc.php:

$mail_settings['use_from_for_all_mail'] = true;

Original comment by: jberanek

jberanek commented 4 years ago

Along with the comment:

// By default MRBS will send some emails (eg booking approval emails) as though they have come from
// the user, rather than the From address above.   However some email servers will not allow this in
// order to prevent email spoofing.   If this is the case then set this to true in order that the
// From address above is used for all emails.

Original comment by: jberanek

jberanek commented 4 years ago

I did this and produced the same error. Any idea?

Original comment by: humbertos

jberanek commented 4 years ago

Try setting

$mail_settings['debug'] = true;

and see what From address is being used.

Original comment by: campbell-m

jberanek commented 4 years ago

From address is from my logged user. Not from the user configured to send mails.

Original comment by: humbertos

jberanek commented 4 years ago

Strange. It seems that setting wasn't there in 1.7.5. I thought it was. It must have come in in 1.8.0. Anyway, you can fix your 1.7.5 system by changing line 754 of functions_mail.inc from

  if (isset($user) && in_array($action, array("more_info", "reject", "remind")))

to

if (false)

Original comment by: campbell-m

jberanek commented 4 years ago

Yes, that setting was only introduced in 1.8.0 after Support Request #1714.

Original comment by: campbell-m

jberanek commented 4 years ago

This worked. Thanks!

Original comment by: humbertos