Skip to content

Commit

Permalink
Added sender_host to messages table to report connected sendmail-wrap…
Browse files Browse the repository at this point in the history
…per host

preparing for 1.0.6 release
  • Loading branch information
onlime committed Jul 24, 2020
1 parent f29e308 commit 59f6662
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# CHANGELOG

## 1.0.6 (UNRELEASED)
## 1.0.6 (2020-07-24)

- Avoid PHP Notices on non-standard mail header lines that don't contain a column, reporting warning to syslog.
- Add `sender_host` to `messages` table, reporting the connected sendmail-wrapper hostname, in case the MySQL database is located on a remote host and sendmail-wrapper is deployed to multiple hosts.

## 1.0.5 (2019-10-29)

Expand Down
6 changes: 3 additions & 3 deletions app/SendmailThrottle.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,10 @@ protected function _logMessage($throttleId, $username, $rcptCount, $status)
$bcc = mb_decode_mimeheader($headerArr['bcc'] ?? null);
$subject = mb_decode_mimeheader($headerArr['subject'] ?? null);

$sql = 'INSERT INTO messages (throttle_id, username, uid, gid, rcpt_count, status, msgid, from_addr, to_addr,
cc_addr, bcc_addr, subject, site, client, script)
$sql = "INSERT INTO messages (throttle_id, username, uid, gid, rcpt_count, status, msgid, from_addr, to_addr,
cc_addr, bcc_addr, subject, site, client, sender_host, script)
VALUES (:throttleId, :username, :uid, :gid, :rcptCount, :status, :msgid, :fromAddr, :toAddr,
:ccAddr, :bccAddr, :subject, :site, :client, :script)';
:ccAddr, :bccAddr, :subject, :site, :client, SUBSTRING_INDEX(USER(), '@', -1), :script)";
$stmt = $this->_pdo->prepare($sql);
$stmt->bindParam(':throttleId', $throttleId);
$stmt->bindParam(':username' , $username);
Expand Down
2 changes: 2 additions & 0 deletions schema/migrations/20200724-add-sender-host.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- 2020-07-24
ALTER TABLE `sendmailwrapper`.`messages` ADD `sender_host` VARCHAR(255) NOT NULL DEFAULT 'localhost' AFTER `client`;
1 change: 1 addition & 0 deletions schema/schema.mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ CREATE TABLE IF NOT EXISTS `sendmailwrapper`.`messages` (
`subject` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'email subject',
`site` VARCHAR(255) NOT NULL DEFAULT '' COMMENT 'site where this email was sent from',
`client` VARCHAR(40) NULL COMMENT 'client IP that invoked the email generation',
`sender_host` VARCHAR(255) NOT NULL DEFAULT 'localhost',
`script` VARCHAR(255) NULL COMMENT 'script that generated this email',
PRIMARY KEY (`id`),
INDEX `fk_messages_throttle_idx` (`throttle_id` ASC),
Expand Down

0 comments on commit 59f6662

Please sign in to comment.