Articles in this section

How to configure MSMTP to use the website domain name instead of the server hostname while sending emails?

kb: how-to Plesk for Linux

Applicable to:

  • Plesk for Linux

Question

  • How to configure MSMTP to use the website domain name instead of the server hostname while sending emails?

Answer

It is not possible to adjust MSMTP settings concerning domains via the Plesk GUI yet, however such a feature request already exists and you may vote for it on the following link:

Allow configuration of MSMTP (SMTP relay) – Your Ideas for Plesk

Top-ranked suggestions are likely to be implemented in future versions of Plesk Obsidian.

As workaround, it is possible to configure MSMTP to send messages from a specific email address that belongs to a domain on the Plesk server by following these steps:

  1. Log in to Plesk server via SSH

  2. Open /etc/msmtprc in text editor and disable auto_from parameter and add from header with desired mail address:

    CONFIG_TEXT: auto_from off
    from test@example.com

When the auto_from is disabled, it is required to explicitly specify a sender email address via the -f (from) option. For example:

# echo "Test Email" | sendmail -f test@example.com test2@example.com

Warning: Notifications from Plesk will not be sent if from test@example.com is not specified while the with auto_from parameter is disabled. Even with from specified in /etc/msmtprc, it is still required to add the from mail address explicitly as shown in the command above.

Was this article helpful?

Comments

1 comment
Date Votes
  • Please be aware that saving the external SMTP settings page will overwrite your changes in /etc/msmtprc

    @see https://talk.plesk.com/threads/change-hostname-for-outgoing-mail-with-msmtp.364553/

    @workaround
    edit /usr/local/psa/admin/sbin/msmtpmng

    mc_generate_msmtp_config()
    {
           local hostname="`hostname -f`"

           printf "${AUTOGENERATED_CONFIGS}\n"
           cat <<-EOT
                   # MSMTP configuration file. See msmtp(1) for syntax.
                   # This file was generated by $prog utility.

                   #
                   # Global settings section
                   #
                   defaults

                   syslog LOG_MAIL

                   tls_certcheck off
                   tls $opt_tls

                   # Automatic envelope-from generation.
                   # Caution: this overrides explicitly set envelope-from via --from.
                   #from %U@$hostname
                   from $opt_auth_user
                   allow_from_override off

                   # This command sets the argument of the SMTP EHLO (or LMTP LHLO) command.
                   domain $hostname

     

    0

Please sign in to leave a comment.