psyadm / backuptools-bash

A little backupscript for Linux (Webdir & MysqlDB's)
MIT License
0 stars 1 forks source link

Pull-Request to Issue #3 #4

Open MrUnknownDE opened 1 month ago

MrUnknownDE commented 1 month ago

The issue #3 be resolved by using msmtp as an alternative to the mail command. This approach does not require a local Mail Transfer Agent (MTA) and can send emails via an SMTP server.

Below is the modified code that uses msmtp:

(
  echo "To: $email"
  echo "Subject: $mailsubject"
  echo "Content-Type: text/plain"
  echo
  cat $mailtext
) | msmtp $email

Steps to Implement the Solution:

  1. Install msmtp on your system. For Debian-based distributions, you can use:

    sudo apt-get install msmtp
  2. Configure msmtp by creating or editing the configuration file ~/.msmtprc with the necessary SMTP server details:

    account default
    host smtp.yourserver.com
    port 587
    from youremail@yourdomain.com
    auth on
    user youremail@yourdomain.com
    password yourpassword
    tls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
  3. Ensure the configuration file has the correct permissions:

    chmod 600 ~/.msmtprc
  4. Update the backup-tool.sh script with the provided code snippet.

  5. Test the script to ensure emails are sent successfully without relying on a local MTA.

This solution ensures that the backup process can run smoothly in environments without an MTA, maintaining the reliabilityand effectiveness of your backup notifications.