1. Hi,


    Need a little help here ;)

    I've been setting up a 12.04 fileserver using RAID1. 2 harddisks. After setting it up I made some changes to the configuration using the "dpkg-reconfigure mdadm" command. I was asked if I wanted the "RAID Monitor Deamon...." to notify by email if a disk gets degraded. And this I would really like to. But, what do I need to install/set-up for the system to be able to send such an email???

    I guess some kind of mail client/smtp. It's a standard Ubuntu Server 12.04 Fileserver setup!

    Looking forward to hear from you ;)

    .
     
  2. srijan

    srijan New Member HowtoForge Supporter

  3. Great !!!!

    Hi Srijan,


    Thanks my friend!!! Just what I've been looking for. Thank you for helping me, again :D

    Question! I'm having trouble understanding this. Anybody who can spell it out for hte clown here!?!? :eek:

    .
     
    Last edited: Aug 25, 2014
  4. Can't get it to send a mail using Gmail

    Hi Srijan,
    and others if you can help ;)


    I installed msmtp, followed the tutorial and tested the system. First I got an login error because of wrong login/password. This was quickly fixed, but then I still got the error:

    msmtp: authentication failed (method PLAIN)

    I checked 1000 pages online and have been trying a lot of stuff. But I can't solve the problem. Anybody who can help me here?

    Here's the problem:

    echo "This is a test e-mail from my server using msmtp" | msmtp -d [email protected]

    Code:
    # echo "This is a test e-mail from my server using msmtp" | msmtp -d [email protected]
    loaded system configuration file /etc/msmtprc
    ignoring user configuration file /root/.msmtprc: No such file or directory
    falling back to default account
    using account default from /etc/msmtprc
    host                  = smtp.gmail.com
    port                  = 587
    timeout               = off
    protocol              = smtp
    domain                = localhost
    auth                  = choose
    user                  = [email protected]
    password              = *
    passwordeval          = (not set)
    ntlmdomain            = (not set)
    tls                   = on
    tls_starttls          = on
    tls_trust_file        = /etc/ssl/certs/ca-certificates.crt
    tls_crl_file          = (not set)
    tls_fingerprint       = (not set)
    tls_key_file          = (not set)
    tls_cert_file         = (not set)
    tls_certcheck         = on
    tls_force_sslv3       = off
    tls_min_dh_prime_bits = (not set)
    tls_priorities        = (not set)
    auto_from             = off
    maildomain            = (not set)
    from                  = [email protected]
    dsn_notify            = (not set)
    dsn_return            = (not set)
    keepbcc               = off
    logfile               = (not set)
    syslog                = LOG_MAIL
    aliases               = (not set)
    reading recipients from the command line
    <-- 220 mx.google.com ESMTP lt7sm552727lac.3 - gsmtp
    --> EHLO localhost
    <-- 250-mx.google.com at your service, [188.179.21.xxx]
    <-- 250-SIZE 35882577
    <-- 250-8BITMIME
    <-- 250-STARTTLS
    <-- 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
    <-- 250-ENHANCEDSTATUSCODES
    <-- 250-CHUNKING
    <-- 250 SMTPUTF8
    --> STARTTLS
    <-- 220 2.0.0 Ready to start TLS
    TLS certificate information:
        Owner:
            Common Name: smtp.gmail.com
            Organization: Google Inc
            Locality: Mountain View
            State or Province: California
            Country: US
        Issuer:
            Common Name: Google Internet Authority G2
            Organization: Google Inc
            Country: US
        Validity:
            Activation time: Tue 15 Jul 2014 10:40:38 AM CEST
            Expiration time: Sat 04 Apr 2015 05:15:55 PM CEST
        Fingerprints:
            SHA1: 9C:0A:CC:93:1D:E7:51:37:90:61:6B:A1:18:28:67:95:54:C5:69:A8
            MD5:  E7:48:1D:0B:99:4A:C3:A8:31:86:E5:8F:E5:EE:4F:2A
    --> EHLO localhost
    <-- 250-mx.google.com at your service, [188.179.21.234]
    <-- 250-SIZE 35882577
    <-- 250-8BITMIME
    <-- 250-AUTH LOGIN PLAIN XOAUTH XOAUTH2 PLAIN-CLIENTTOKEN
    <-- 250-ENHANCEDSTATUSCODES
    <-- 250-CHUNKING
    <-- 250 SMTPUTF8
    --> AUTH PLAIN AGhvc3RtYXN0ZXIuZGFuaGFuc2VuQGdtYWlsLmNvbQBkYW5yYXkxMjEy
    <-- 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbt1u
    <-- 534-5.7.14 ncLRqS0MPxkLlU9vKObZsvWqBEJxcP8AKIYondhsnHNk_RAmTsXIu1oSpM9LQlSh3qJRfu
    <-- 534-5.7.14 Vjh-WVZ2LnRDC2Slwv5JcttYFBFdMkzizDZy5FHWdCmDIVJ_rS_bkwu9wUQ__IqZHa8JEG
    <-- 534-5.7.14 LWeWNmz4JMsh5St9HXyYi8MyfgUmqIZgpahWEkcn-zZQtcntn0-ivtVQ7tgUgVuyWNY1SY
    <-- 534-5.7.14 evo--cA> Please log in via your web browser and then try again.
    <-- 534-5.7.14 Learn more at
    <-- 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754.X lt7sm552727lac.3 - gsmtp
    msmtp: authentication failed (method PLAIN)
    msmtp: server message: 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbt1u.X
    msmtp: server message: 534-5.7.14 ncLRqS0MPxkLlU9vKObZsvWqBEJxcP8AKIYondhsnHNk_RAmTsXIu1oSpM9LQlSh3qJRfu
    msmtp: server message: 534-5.7.14 Vjh-WVZ2LnRDC2Slwv5JcttYFBFdMkzizDZy5FHWdCmDIVJ_rS_bkwu9wUQ__IqZHa8JEG
    msmtp: server message: 534-5.7.14 LWeWNmz4JMsh5St9HXyYi8MyfgUmqIZgpahWEkcn-zZQtcntn0-ivtVQ7tgUgVuyWNY1SY
    msmtp: server message: 534-5.7.14 evo--cA> Please log in via your web browser and then try again.
    msmtp: server message: 534-5.7.14 Learn more at
    msmtp: server message: 534 5.7.14 https://support.google.com/mail/bin/answer.py?answer=78754.X lt7sm552727lac.3 - gsmtp
    msmtp: could not send mail (account default from /etc/msmtprc)
    
    


    Here's my config files:

    /etc/msmtprc

    Code:
    [COLOR="Blue"]# vi /etc/msmtprc                                    
    ##### SAMPLE ACCOUNT - OUTCOMMENTED #####
    ## Sympatico Account
    #account sympatico
    #host smtphm.sympatico.ca
    #from [email protected]
    #tls on
    #tls_starttls on
    #tls_trust_file /etc/ssl/certs/ca-certificates.crt
    #auth on
    #user [email protected]
    #password ********
    #syslog LOG_MAIL
    
    ## Rogers Account
    #account rogers
    #host mail.domain.tld
    #port 587
    #from [email protected]
    #auth login
    #user [email protected]
    #password ********
    #syslog LOG_MAIL
    
    ## gmail account
    ## Configuring for gmail is beyond the scope of this tutorial
    ## Googling for "gmail msmtp" should help[/COLOR]
    account gmail
    host smtp.gmail.com
    port 587
    from [email protected]
    tls on
    tls_starttls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
    auth on
    user [email protected]
    password mypassword
    syslog LOG_MAIL
    
    
    [COLOR="Blue"]# Other ISP Account
    # Configuring for other ISPs is beyond the scope of this tutorial
    # Googling for "myisp outlook smtp" should help
    
    # ------------------------------------------------------------------------------
    # Configurations
    # ------------------------------------------------------------------------------
    
    # Construct envelope-from addresses of the form "[email protected]".
    #auto_from on
    #maildomain fermmy.server
    
    # Use TLS.
    #tls on
    #tls_trust_file /etc/ssl/certs/ca-certificates.crt
    # Syslog logging with facility LOG_MAIL instead of the default LOG_USER.
    # Must be done within "account" sub-section above
    #syslog LOG_MAIL
    
    # Set a default account[/COLOR]
    account default : gmail
    
    [COLOR="Blue"]# ------------------------------------------------------------------------------[/COLOR]
    
    
    Tried:
    1.
    Using this:
    Code:
    tls_trust_file /usr/share/ca-certificates/mozilla/Equifax_Secure_CA.crt
    instead of:
    Code:
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
    2.
    Code:
    chmod 0644 /etc/msmtprc
    3.
    Code:
    port                  = 465
    instead of
    Code:
    port                  = 587
    4.
    Simple version of:
    /etc/msmtprc

    Code:
    # vi /etc/msmtprc
    defaults
    tls on
    tls_starttls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
    
    account default
    host smtp.gmail.com
    port 587
    auth on
    user [email protected]
    password mypassword
    from [email protected]
    logfile /var/log/msmtp.log
     
    Last edited: Aug 25, 2014
  5. works when using another mailserver/emailaccount

    Hi,


    It works just fine, when testing with another mailserver/mailaccount:

    Code:
    # echo "This is a test e-mail from my server using msmtp" | msmtp -d [email protected]
    loaded system configuration file /etc/msmtprc
    ignoring user configuration file /root/.msmtprc: No such file or directory
    falling back to default account
    using account default from /etc/msmtprc
    host                  = mail.domain.dk
    port                  = 25
    timeout               = off
    protocol              = smtp
    domain                = localhost
    auth                  = LOGIN
    user                  = [email protected]
    password              = *
    passwordeval          = (not set)
    ntlmdomain            = (not set)
    tls                   = off
    tls_starttls          = on
    tls_trust_file        = (not set)
    tls_crl_file          = (not set)
    tls_fingerprint       = (not set)
    tls_key_file          = (not set)
    tls_cert_file         = (not set)
    tls_certcheck         = on
    tls_force_sslv3       = off
    tls_min_dh_prime_bits = (not set)
    tls_priorities        = (not set)
    auto_from             = off
    maildomain            = (not set)
    from                  = [email protected]
    dsn_notify            = (not set)
    dsn_return            = (not set)
    keepbcc               = off
    logfile               = (not set)
    syslog                = LOG_MAIL
    aliases               = (not set)
    reading recipients from the command line
    <-- 220 server.domain.dk ESMTP Postfix (Ubuntu)
    --> EHLO localhost
    <-- 250-server.domain.dk
    <-- 250-PIPELINING
    <-- 250-SIZE
    <-- 250-VRFY
    <-- 250-ETRN
    <-- 250-STARTTLS
    <-- 250-AUTH PLAIN LOGIN
    <-- 250-AUTH=PLAIN LOGIN
    <-- 250-ENHANCEDSTATUSCODES
    <-- 250-8BITMIME
    <-- 250 DSN
    --> AUTH LOGIN
    <-- 334 VXNlcm5hbWU6
    --> bWFpbEBpbGRlcnNob3AuZGs=
    <-- 334 UGFzc3dvcmQ6
    --> ZGFucmF5NTA1MA==
    <-- 235 2.7.0 Authentication successful
    --> MAIL FROM:<[email protected]>
    --> RCPT TO:<[email protected]>
    --> DATA
    <-- 250 2.1.0 Ok
    <-- 250 2.1.5 Ok
    <-- 354 End data with <CR><LF>.<CR><LF>
    --> This is a test e-mail from my server using msmtp
    --> .
    <-- 250 2.0.0 Ok: queued as C2FEA20228B
    --> QUIT
    <-- 221 2.0.0 Bye
    
    Tried:
    1. Use port 25 for smtp to Gmail mailserver, didn't work.
    2. to change "auth on" to auth login" for smtp to Gmail mailserver, didn't work.

    .
     
    Last edited: Aug 25, 2014
  6. Thanks Srijan ;)

    Hi Srijan,


    Well, I succeeded in setting up the system, so that a warning mail from the RAID Monitor Deamon can be sent from the fileserver, if & when a array gets degraded!
    But, I still want to be able to sent it using the Gmail SMTP, and this I haven't cracked yet. So please help me with that ;)

    Code:
    This is an automatically generated mail message from mdadm
    running on servername.domain.dk
    
    A DegradedArray event had been detected on md device /dev/md/1.
    
    Faithfully yours, etc.
    
    P.S. The /proc/mdstat file currently contains the following:
    
    Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
    md1 : active raid1 sda2[0]
          483267392 blocks super 1.2 [2/1] [U_]
    
    md0 : active raid1 sda1[0] sdb1[1]
          1950656 blocks super 1.2 [2/2] [UU]
     
  7. srijan

    srijan New Member HowtoForge Supporter

  8. SOLVED! Gmail settings has to be changed...

    Hi,


    At last I cracked it... The problem was "modern security systems" for services such as Gmail.

    Changing the settings for the Gmail account you want to use, solves the problem ;)

    Here's how you do it:

    1. Allowing less secure apps to access your Gmail account:
    Log in to your Gmail account from your computer, not your smartphone. Goto this url:
    https://www.google.com/settings/security/lesssecureapps
    and choose "Allow"

    Here's some additional information:
    Code:
    Allowing less secure apps to access your account
    
    Google may block sign in attempts from some apps or devices that do not use modern security standards. Since these apps and devices are easier to break into, blocking them helps keep your account safer.
    
    Some examples of apps that do not support the latest security standards include:
    
        The Mail app on your iPhone or iPad with iOS 6 or below
        The Mail app on your Windows phone preceding the 8.1 release
        Some Desktop mail clients like Microsoft Outlook and Mozilla Thunderbird
    
    Access your account
    
    To help keep your account secure, we may block these less secure apps from accessing your account, and you’ll see a “Password incorrect” error when trying to sign in. If this is the case, you have two options:
    
    Upgrade to a more secure app that uses the most up to date security measures. All Google products, like Gmail, use the latest security measures.
    Go to Allow less secure apps and choose “Allow” to let less secure apps access your Google account. We don't recommend this option because it may make it easier for someone to gain access to your account.
    
    2. Sample of an MSMTP config file. Replace red markins with your own information:
    # vi /etc/msmtprc
    Code:
    defaults
    tls on
    tls_starttls on
    tls_trust_file /etc/ssl/certs/ca-certificates.crt
    
    account default
    host smtp.gmail.com
    port 587
    auth on
    user [COLOR="Red"]youremail[/COLOR]@gmail.com
    password [COLOR="Red"]******[/COLOR]
    from [COLOR="Red"]youremail[/COLOR]@gmail.com
    logfile /var/log/msmtp.log
    
    3. Test it using this command line. Replace red markins with your own information:
    Code:
    # echo -e "Subject: MSMTP Test Mail\r\n\r\nThis is a test e-mail from my server using msmtp" | msmtp --debug --from=default -t [COLOR="Red"]youremail[/COLOR]@gmail.com

    That's it! If you have been following this thread, you've seen/followed the same setups/configurations as me and then it'll all work now.
    If not, please let me know and then I'll write a ToDO for you ;) You can just post a reply here and I'll see it.

    Thanks for the help Mr. Srijan ;)
     
    Last edited: Aug 27, 2014

Share This Page