meeting-room-booking-system / mrbs-code

MRBS application code
Other
120 stars 59 forks source link

Notification e-mails not working #2123

Open jberanek opened 6 years ago

jberanek commented 6 years ago

Hi, This project is great. You guys have done a good job with this. Thank you. However, I'm having problems with the mail settings. We're using Office 365, and I'm trying to use SMTP to send out the notification e-mails. Here is the code in my config.inc.php file:

// E-mail settings $url_base = "http://172.16.30.231"; // Current IP address of the test server $mail_settings['admin_lang'] = 'en'; $mail_settings['admin_backend'] = 'mail'; $smtp_settings['host'] = 'smtp.office365.com'; // SMTP server $smtp_settings['port'] = 587; // SMTP port number $smtp_settings['auth'] = true; // Whether to use SMTP authentication $smtp_settings['secure'] = 'tls'; // Encryption method: '', 'tls' or 'ssl' $smtp_settings['username'] = 'e-mail address of MRBS'; // Username (if using authentication) $smtp_settings['password'] = 'Password of the above e-mail'; // Password (if using authentication) // When an e-mail is sent $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 // Who e-mail is sent to $mail_settings['area_admin_on_bookings'] = true; // the area administrator $mail_settings['booker'] = true; // the person making the booking

We use IMAP_PHP authentication, which is working well. I have added myself as the area admin. Based on the above code, I should be getting 2 e-mail notifications when I create an entry: 1 sent back to me as the booker, and 1 sent to me as the area admin. However, I'm not getting anything. Can you tell me what I'm doing wrong?

Reported by: *anonymous

Original Ticket: mrbs/support-requests/1412

jberanek commented 6 years ago

I'd turn on debugging to get more information. Set the following in your config file:

$mail_settings['debug'] = true;

By default the output will go to your PHP error log. If you don't know where that is then you can send it to the browser by setting

$mail_settings['debug_output'] = 'browser';

Original comment by: campbell-m

jberanek commented 6 years ago

Just noticed - assuming you are wanting to send mail using smtp, you need to set

$mail_settings['admin_backend'] = 'smtp';  // instead of 'mail'

Original comment by: campbell-m

jberanek commented 6 years ago

That is correct. Sorry about that. I did make that change. Here is the output in the browser:

[DEBUG] Preparing email for deleted booking [DEBUG] Preparing to send email ... [DEBUG] Using backend 'smtp' [DEBUG] Recipients: 'mcrockett@rvu.edu' Connection: opening to smtp.office365.com:587, timeout=300, options=array ( 'ssl' => array ( 'verify_peer' => true, 'verify_peer_name' => true, 'allow_self_signed' => false, ),) Connection: opened SERVER -> CLIENT: 220 CY4PR20CA0021.outlook.office365.com Microsoft ESMTP MAIL Service ready at Fri, 12 Jan 2018 18:33:43 +0000 CLIENT -> SERVER: EHLO 172.16.30.231 SERVER -> CLIENT: 250-CY4PR20CA0021.outlook.office365.com Hello [209.33.250.98]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-STARTTLS250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8 CLIENT -> SERVER: STARTTLS SERVER -> CLIENT: 220 2.0.0 SMTP server ready CLIENT -> SERVER: EHLO 172.16.30.231 SERVER -> CLIENT: 250-CY4PR20CA0021.outlook.office365.com Hello [209.33.250.98]250-SIZE 157286400250-PIPELINING250-DSN250-ENHANCEDSTATUSCODES250-AUTH LOGIN XOAUTH2250-8BITMIME250-BINARYMIME250-CHUNKING250 SMTPUTF8 CLIENT -> SERVER: AUTH LOGIN SERVER -> CLIENT: 334 VXNlcm5hbWU6 CLIENT -> SERVER: dXRzcmJzQHJ2dS5lZHU= SERVER -> CLIENT: 334 UGFzc3dvcmQ6 CLIENT -> SERVER: Wm9vbGFuZGVyMSE= SERVER -> CLIENT: 235 2.7.0 Authentication successful target host BLUPR02MB1106.namprd02.prod.outlook.com CLIENT -> SERVER: MAIL FROM:admin_email@your.org SERVER -> CLIENT: 250 2.1.0 Sender OK CLIENT -> SERVER: RCPT TO:mcrockett@rvu.edu SERVER -> CLIENT: 250 2.1.5 Recipient OK CLIENT -> SERVER: DATA SERVER -> CLIENT: 354 Start mail input; end with . CLIENT -> SERVER: Date: Fri, 12 Jan 2018 11:33:42 -0700 CLIENT -> SERVER: To: mcrockett@rvu.edu CLIENT -> SERVER: From: admin_email@your.org CLIENT -> SERVER: Subject: Entry deleted for RVUCOM-SU MRBS CLIENT -> SERVER: Message-ID: fdadc8d38caf06d136e05a7791947650@172.16.30.231 CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.21 (https://github.com/PHPMailer/PHPMailer) CLIENT -> SERVER: Auto-Submitted: auto-generated CLIENT -> SERVER: MIME-Version: 1.0 CLIENT -> SERVER: Content-Type: multipart/alternative; CLIENT -> SERVER: boundary="=_f2dc1e7a71437c883695b3e0490b5350"; charset=utf-8 CLIENT -> SERVER: CLIENT -> SERVER: --=_f2dc1e7a71437c883695b3e0490b5350 CLIENT -> SERVER: Content-Transfer-Encoding: 8bit CLIENT -> SERVER: Content-Type: text/plain; charset=utf-8 CLIENT -> SERVER: CLIENT -> SERVER: An entry has been deleted, here are the details: CLIENT -> SERVER: CLIENT -> SERVER: Deleted by: mcrockett@rvu.edu CLIENT -> SERVER: CLIENT -> SERVER: CLIENT -> SERVER: Name: Mike's test CLIENT -> SERVER: CLIENT -> SERVER: --=_f2dc1e7a71437c883695b3e0490b5350-- CLIENT -> SERVER: CLIENT -> SERVER: . SERVER -> CLIENT: 550 5.7.60 SMTP; Client does not have permissions to send as this sender [BLUPR02MB1106.namprd02.prod.outlook.com] SMTP ERROR: DATA END command failed: 550 5.7.60 SMTP; Client does not have permissions to send as this sender [BLUPR02MB1106.namprd02.prod.outlook.com] SMTP Error: data not accepted. [DEBUG] Failed to send email: SMTP Error: data not accepted.SMTP server error: DATA END command failed Detail: 5.7.60 SMTP; Client does not have permissions to send as this sender [BLUPR02MB1106.namprd02.prod.outlook.com] SMTP code: 550 CLIENT -> SERVER: QUIT SERVER -> CLIENT: 221 2.0.0 Service closing transmission channel Connection: closed

So, permissions? Not sure how I would resolve this in Office 365.

Original comment by: *anonymous

jberanek commented 6 years ago

You appear to have left the following setting at the default, you need to update it to a valid email address in your config.inc.php:

$mail_settings['from'] = 'admin_email@your.org';

Original comment by: jberanek

jberanek commented 6 years ago

Ah! I saw that setting, and was about to try it, just before I saw your reply. It all works now. I would recommend that in the systemdefaults.inc.php file, this should probably not be under the EMAIL - MISCELLANEOUS section. Because this is a required setting, I would expect to find it higher in the list of settings. Just a thought. But you guys are awesome. Thanks again.

Original comment by: *anonymous

jberanek commented 6 years ago

Good idea. I've made the change in dc4d32.

Original comment by: campbell-m

jberanek commented 6 years ago

I've also improved the debug output in ec9eea splitting out the From, To, Cc and Bcc addresses.

Original comment by: campbell-m