Results 1 to 6 of 6

Thread: smartd test email fails to send / How to specify "from:" address used by smartd?

  1. #1

    Question smartd test email fails to send / How to specify "from:" address used by smartd?

    Hello All,

    smartd can not successful complete sending an email test message because:
    1) I could not find a way to make smartd specify the "from:" address in the outgoing email test message; or
    2) I do not know how to make Postfix always use a user-specified "from:" address

    Please help me get smartd to successfully complete sending an email test message. I would strongly prefer making smartd specify the "from:" address, rather than making changes to Postfix.

    Details follow.

    Here is the contents of /etc/smartd.conf
    Code:
    /dev/sda -a -d sat -M test -m recipient@q.com -n standby,3,q -o on -S on  -s (S/../.././(00|06|12|18)|L/../(01|05|10|15|20|25)/./(00|06|12|18))  -W 5,51,54
    smartd thinks it succeeded sending the test email:
    Code:
    LinuxBox:/ # service smartd status
    smartd.service - Self Monitoring and Reporting Technology (SMART) Daemon
       Loaded: loaded (/usr/lib/systemd/system/smartd.service; enabled)
       Active: active (running) since Fri 2014-05-09 16:52:28 MDT; 41s ago
     Main PID: 2951 (smartd)
       CGroup: /system.slice/smartd.service
               `-2951 /usr/sbin/smartd -n
    May 09 16:52:28 LinuxBox.site smartd[2951]: Device: /dev/sda [SAT], is SMART capable. Adding to "monitor" list.
    May 09 16:52:28 LinuxBox.site smartd[2951]: Device: /dev/sda [SAT], state read from /var/lib/smartmontools/smartd.ST3320620NS-5QF2ZLX6.ata.state
    May 09 16:52:28 LinuxBox.site smartd[2951]: Monitoring 1 ATA and 0 SCSI devices
    May 09 16:52:28 LinuxBox.site smartd[2951]: Executing test of <mail> to recipient@q.com ...
    May 09 16:52:28 LinuxBox.site smartd[2951]: Test of <mail> to recipient@q.com: successful
    May 09 16:52:28 LinuxBox.site smartd[2951]: Device: /dev/sda [SAT], initial Temperature is 31 Celsius (Min/Max 33/35)
    May 09 16:52:28 LinuxBox.site smartd[2951]: Device: /dev/sda [SAT], SMART Usage Attribute: 190 Airflow_Temperature_Cel changed from 74 to 69
    May 09 16:52:28 LinuxBox.site smartd[2951]: Device: /dev/sda [SAT], SMART Usage Attribute: 194 Temperature_Celsius changed from 26 to 31
    May 09 16:52:28 LinuxBox.site smartd[2951]: Device: /dev/sda [SAT], SMART Usage Attribute: 195 Hardware_ECC_Recovered changed from 94 to 81
    May 09 16:52:28 LinuxBox.site smartd[2951]: Device: /dev/sda [SAT], state written to /var/lib/smartmontools/smartd.ST3320620NS-xxxxxxxx.ata.state
    BUT, the test message never gets delivered.

    When I examine the Postfix log, it reveals the receiving SMTP server bounced smartd's test email because the SMTP server could not determine the test message's proper sender:
    Code:
    2014-05-09T16:52:28.896883-06:00 LinuxBox postfix/pickup[2897]: DAEA314245: uid=0 from=<root>
    2014-05-09T16:52:28.898026-06:00 LinuxBox postfix/cleanup[2938]: DAEA314245: message-id=<20140509225228.DAEA314245@LinuxBox.site>
    2014-05-09T16:52:28.921660-06:00 LinuxBox postfix/qmgr[2898]: DAEA314245: from=<root@LinuxBox.site>, size=769, nrcpt=1 (queue active)
    2014-05-09T16:52:29.404586-06:00 LinuxBox postfix/smtp[2940]: DAEA314245: to=<recipient@q.com>, relay=smtp.q.com[205.169.121.111]:587, delay=0.5, delays=0.05/0/0.43/0.03, dsn=5.0.0, status=bounced (host smtp.q.com[205.169.121.111] said: 550 Could not resolve sender's domain (in reply to MAIL FROM command))
    I know Postfix is configured correctly, because I manually sent a message successfully:
    Code:
    LinuxBox:/ # mailx -s "Testing" -r recipient@q.com sender@q.com
    Testing
    EOT
    BTW - I know just barely enough to get Postfix set up using YaST.

    Note:
    The actual email addresses used were sanitized for security.

    System details:
    openSUSE 13.1 for x86_64
    smartmontools-6.2-95.1.x86_64 (where smartd is from)
    postfix-2.9.6-7.4.1.x86_64
    Linux kernel 3.11.10-7-desktop

  2. #2
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: smartd test email fails to send / How to specify "from:" addressused by smartd?

    On 2014-05-10 02:06, Max314 wrote:
    >
    > Hello All,
    >
    > smartd can not successful -complete- sending an email test message
    > because:
    > 1) I could not find a way to make smartd specify the "from:" address in
    > the outgoing email test message; or


    I think I have that problem on another machine, but I have not
    investigated it yet. I did see the bounces. I must have a better look.


    --
    Cheers / Saludos,

    Carlos E. R.

    (from 13.1 x86_64 "Bottle" (Minas Tirith))

  3. #3

    Default Re: smartd test email fails to send / How to specify "from:" addressused by smartd?

    Quote Originally Posted by robin_listas View Post
    On 2014-05-10 02:06, Max314 wrote:
    >
    > Hello All,
    >
    > smartd can not successful -complete- sending an email test message
    > because:
    > 1) I could not find a way to make smartd specify the "from:" address in
    > the outgoing email test message; or


    I think I have that problem on another machine, but I have not
    investigated it yet. I did see the bounces. I must have a better look.
    Thank you for your effort. I appreciate any help you have to offer.

    Ever since openSUSE 12.2, I have not been able to get smartd to successfully complete sending a test email, despite much time and effort spent, and that has been very frustrating.

  4. #4
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: smartd test email fails to send / How to specify "from:" addressused by smartd?

    On 2014-05-10 03:18, Carlos E. R. wrote:
    > On 2014-05-10 02:06, Max314 wrote:
    >>
    >> Hello All,
    >>
    >> smartd can not successful -complete- sending an email test message
    >> because:
    >> 1) I could not find a way to make smartd specify the "from:" address in
    >> the outgoing email test message; or

    >
    > I think I have that problem on another machine, but I have not
    > investigated it yet. I did see the bounces. I must have a better look.


    Ok, testing this thing. The machine I have problems with is my desktop,
    but at the moment I only have the laptop. I tested with this line taken
    from the man page:

    Code:
    echo /dev/sda -m cer@localhost -M test | smartd -c - -q onecheck
    I don't know what the "-M" does, not in the manual. BUT, I have notes
    from an older manual or different manual that says:

    Code:
    -m ADD  Send warning email to ADD for -H, -l error, -l selftest, and -f
    -M TYPE Modify email warning behavior (see man page)
    So it must be somewhere (and I knew about it when I wrote that note!).
    Anyway, the test email I got fine.

    Code:
    Return-Path: <root@minas-tirith.valinor>
    X-Original-To: cer@localhost
    Delivered-To: cer@localhost.valinor
    Received: by minas-tirith.valinor (Postfix, from userid 0)
    id 83BF1183EDF; Sun, 11 May 2014 21:46:29 +0200 (CEST)
    Date: Sun, 11 May 2014 21:46:29 +0200
    To: cer@localhost.valinor
    Subject: SMART error (EmailTest) detected on host: minas-tirith
    User-Agent: Heirloom mailx 12.5 7/5/10
    MIME-Version: 1.0
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Message-Id: <20140511194629.83BF1183EDF@minas-tirith.valinor>
    From: root@minas-tirith.valinor (root)
    
    This message was generated by the smartd daemon running on:
    
    host name:  minas-tirith
    DNS domain: valinor
    
    The following warning/error was logged by the smartd daemon:
    
    TEST EMAIL from smartd for device: /dev/sda [SAT]
    
    Device info:
    ST9500325AS, S/N:......., 500 GB
    
    For details see host's SYSLOG.
    So, for your problem then, as I can't examine my desktop machine at the
    moment. Your problem is that you are sending to an outside, internet
    address, when the email address FQDN is obviously faked (as is mine).

    Well, I found a little jewel: there is a file named
    "/etc/smartd_warning.sh", that is actually used for sending the email,
    and which you can modify!

    Code:
    # Send mail or run command
    if [ -n "$SMARTD_ADDRESS" ]; then
    
    # Send mail, use platform mailer by default
    test -n "$SMARTD_MAILER" || SMARTD_MAILER=$os_mailer
    if [ -n "$dryrun" ]; then
    echo "exec '$SMARTD_MAILER' -s '$SMARTD_SUBJECT Mío' $SMARTD_ADDRESS
    <<EOF
    $fullmessage
    EOF"
    else
    exec "$SMARTD_MAILER" -s "$SMARTD_SUBJECT Mío 2" $SMARTD_ADDRESS <<EOF
    $fullmessage
    EOF
    fi

    I added the words "mío" and "mío 2" to see if it was used, did a test
    job, and bingo, got the email:

    Code:
    Date: Sun, 11 May 2014 22:05:44 +0200
    From: root <root@minas-tirith.valinor>
    To: cer@localhost.valinor
    Subject: SMART error (EmailTest) detected on host: minas-tirith Mío 2
    It executed the second concoction.


    So... openSUSE "mail" command is not the classic one, but mailx. And in
    this one you can set the sender address like this:

    Code:
    -r address
    Sets  the  From  address. Overrides
    any  from  variable  specified   in
    environment   or   startup   files.
    Tilde escapes are disabled.  The -r
    address  options  are passed to the
    mail transfer agent unless SMTP  is
    used.   This option exists for com-
    patibility only; it is  recommended
    to  set  the from variable directly
    instead.
    So you have to modify the script to add that parameter (I have not
    investigated the warning about "set(ting) the from variable directly
    instead". On other occassions I have used this "-r", if my memory serves
    me right (and it doesn't always - sigh).


    Code:
    exec "$SMARTD_MAILER" -r "good_sender@q.com" -s "$SMARTD_SUBJECT"
    $SMARTD_ADDRESS <<EOF

    That should work. Of course, your postfix must be setup to talk to your
    ISP and be able to send as "good_sender@q.com" - if it needs
    authentication, that can be done.


    HTH :-)


    --
    Cheers / Saludos,

    Carlos E. R.

    (from 13.1 x86_64 "Bottle" (Minas Tirith))

  5. #5

    Default Re: smartd test email fails to send / How to specify "from:" addressused by smartd?

    Quote Originally Posted by robin_listas View Post
    On 2014-05-10 03:18, Carlos E. R. wrote:
    Your problem is that you are sending to an outside, internet
    address, when the email address FQDN is obviously faked (as is mine).
    I'm not sure I understand what you mean here. When you say "an outside, internet address", are you referring to the SMTP server's address, the message's destination email address, or something else? Also, please elaborate what you mean by "faked".

    The "To:" email address I configured smartd to use for sending the test message is a legitimate address. I do not own a domain, so the SMTP server being used by smartd/Postfix to sent the test email lives at my ISP, smtp.q.com (CenturyLink).


    Quote Originally Posted by robin_listas View Post
    Well, I found a little jewel: there is a file named
    "/etc/smartd_warning.sh", that is actually used for sending the email,
    and which you can modify!

    Code:
    # Send mail or run command
    if [ -n "$SMARTD_ADDRESS" ]; then
    
    # Send mail, use platform mailer by default
    test -n "$SMARTD_MAILER" || SMARTD_MAILER=$os_mailer
    if [ -n "$dryrun" ]; then
    echo "exec '$SMARTD_MAILER' -s '$SMARTD_SUBJECT Mío' $SMARTD_ADDRESS
    <<EOF
    $fullmessage
    EOF"
    else
    exec "$SMARTD_MAILER" -s "$SMARTD_SUBJECT Mío 2" $SMARTD_ADDRESS <<EOF
    $fullmessage
    EOF
    fi

    I added the words "mío" and "mío 2" to see if it was used, did a test
    job, and bingo, got the email:

    Code:
    Date: Sun, 11 May 2014 22:05:44 +0200
    From: root <root@minas-tirith.valinor>
    To: cer@localhost.valinor
    Subject: SMART error (EmailTest) detected on host: minas-tirith Mío 2
    It executed the second concoction.


    So... openSUSE "mail" command is not the classic one, but mailx. And in
    this one you can set the sender address like this:

    Code:
    -r address
    Sets  the  From  address. Overrides
    any  from  variable  specified   in
    environment   or   startup   files.
    Tilde escapes are disabled.  The -r
    address  options  are passed to the
    mail transfer agent unless SMTP  is
    used.   This option exists for com-
    patibility only; it is  recommended
    to  set  the from variable directly
    instead.
    So you have to modify the script to add that parameter (I have not
    investigated the warning about "set(ting) the from variable directly
    instead". On other occassions I have used this "-r", if my memory serves
    me right (and it doesn't always - sigh).


    Code:
    exec "$SMARTD_MAILER" -r "good_sender@q.com" -s "$SMARTD_SUBJECT"
    $SMARTD_ADDRESS <<EOF
    Are you suggesting there is a bug in the current version of smartd?

  6. #6
    Join Date
    Feb 2009
    Location
    Spain
    Posts
    25,547

    Default Re: smartd test email fails to send / How to specify "from:" addressused by smartd?

    On 2014-05-11 23:56, Max314 wrote:
    >
    > robin_listas;2642542 Wrote:
    >>
    >> On 2014-05-10 03:18, Carlos E. R. wrote:
    >> Your problem is that you are sending to an outside, internet
    >> address, when the email address FQDN is obviously *faked* (as is mine).
    >>

    > I'm not sure I understand what you mean here. When you say "an
    > outside, internet address", are you referring to the SMTP server's
    > address, the message's destination email address, or something else?
    > Also, please elaborate what you mean by "faked".


    Your from address. You used "root@LinuxBox.site", I used
    "root@minas-tirith.valinor". Both are "faked", not real internet
    addresses. The "To" address you use is, in your case, a real Internet
    address.

    I do not own a domain either.



    > Are you suggesting there is a bug in the current version of smartd?


    Not at all.

    They provide a script that does the job of sending the email, which you
    can customize for your own uses. In this case you probably only need to
    add a good "from" address, but you might also use it to send an SMS to
    your mobile phone.

    --
    Cheers / Saludos,

    Carlos E. R.

    (from 13.1 x86_64 "Bottle" (Minas Tirith))

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •