Welcome to Centmin Mod Community
Become a Member

Email root email forward

Discussion in 'Domains, DNS, Email & SSL Certificates' started by ahmed, Apr 25, 2017.

  1. ahmed

    ahmed Member

    243
    19
    18
    Feb 21, 2017
    Ratings:
    +26
    Local Time:
    5:29 PM
    Hello

    for the forarding address that I will put here:

    nano /root/.forward

    to get the server emails, what port do I need to open? 25?

    also is it important to do that?

    does it have a side effect by opening that port?
     
  2. johanguse

    johanguse New Member

    10
    3
    3
    Apr 25, 2017
    Ratings:
    +3
    Local Time:
    1:29 PM
    1.11.13
    Yes 25! It's possible to send this e-mails from centminmod with transactional emails server? Like SparkPost, Mandrill, Sendgrid?
     
    • Like Like x 1
  3. ahmed

    ahmed Member

    243
    19
    18
    Feb 21, 2017
    Ratings:
    +26
    Local Time:
    5:29 PM
    Thanks a lot, looks like google server is not allowing this, I have sendgrid, how to use that with sendgrid please?
     
  4. johanguse

    johanguse New Member

    10
    3
    3
    Apr 25, 2017
    Ratings:
    +3
    Local Time:
    1:29 PM
    1.11.13
    I want to know too.... maybe editing Postfix but I'm not sure.
     
  5. johanguse

    johanguse New Member

    10
    3
    3
    Apr 25, 2017
    Ratings:
    +3
    Local Time:
    1:29 PM
    1.11.13
  6. eva2000

    eva2000 Administrator Staff Member

    37,257
    8,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,531
    Local Time:
    1:29 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    what do you want to do ? have emails that are set to root user forwarded to your gmail/google app email address ?

    Then all you need is to add gmail/google app email to /root/.forward to use server Postfix SMTP.

    Postfix is configured for sending out emails for all domains out of box. So you're all taken care of for any site hosted on your server for Postfix outgoing emails sent from the main host name so emails sent from @mainhost.domain.com. Which is why Getting Started Guide step 1 for proper main hostname DNS configuration is important for properly email delivery via Postfix and also mentioned at Email - Steps to ensure your site/server email doesn't end up in spam inboxes | Centmin Mod Community

    However, if you use some web hosts like Vultr they block SMTP port by default until you contact support to unblock you for your account - you may need to provide verification ID for them to unblock your SMTP port. They do this to reduce spam. Once unblocked all future Vultr servers created have SMTP unblocked.
     
  7. eva2000

    eva2000 Administrator Staff Member

    37,257
    8,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,531
    Local Time:
    1:29 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    if you want to setup Postfix relay so all server emails are sent from a 3rd party SMTP server like Sengrid or Amazon SES transactional email, then yes need to follow their postfix relay setup guides. If unsure where a config file is and it was installed via YUM, you can use rpm -ql command to list the YUM packages installed files' locations i.e.

    on CentOS 7 postfix yum package list and then grep filter for main.cf to see where it is
    Code (Text):
    rpm -ql postfix | grep main.cf
    

    you get /etc/postfix/main.cf is the file path
    Code (Text):
    rpm -ql postfix | grep main.cf
    /etc/postfix/main.cf
    /usr/libexec/postfix/main.cf
    /usr/share/doc/postfix-2.10.1/main.cf.default
    

     
  8. noly

    noly Member

    93
    13
    8
    Jul 24, 2017
    Germany
    Ratings:
    +25
    Local Time:
    4:29 PM
    1.13.x
    10.x
    Strange, i can't find ".forward" in /root
    Or am i supposed to create that file?

    The way i set it up having server notifications be send via email is actually just adding
    Code:
    EMAIL='[email protected]'
    to the custom_config.inc

    For a better understanding:
    Do the different approaches (1. .forward, 2. edit /etc/aliases and adding -> root: [email protected]) have different
    rights to exist?
     
    Last edited: Nov 27, 2017
  9. eva2000

    eva2000 Administrator Staff Member

    37,257
    8,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,531
    Local Time:
    1:29 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
    EMAIL= variable right now is only used by addons/maldet.sh addon for maldet email notifications but in future maybe used elsewhere

    /etc/aliases or /root/.forward both do the same thing with former having more control over configuration with more steps i.e. newaliases command + restarting postfix service etc https://wiki.centos.org/HowTos/postfix#head-cbec8da04bf5871b09fb00077e3e591a85a5d94d

    While latter is simple as adding email address in it for [email protected] sent system emails.
     
  10. noly

    noly Member

    93
    13
    8
    Jul 24, 2017
    Germany
    Ratings:
    +25
    Local Time:
    4:29 PM
    1.13.x
    10.x
    Well...i don't have maldet.sh installed and since that means this line is obsolete i have commented it out until "future maybe used elsewhere".

    I got that from your gist:

    https://gist.github.com/centminmod/bb1c8a164d2d453073b1

    and there it is only stated:

    Code:
    EMAIL=' '          # Server notification email address enter only 1 address
    And here you recommend to change LF_ALERT_TO and LF_ALERT_FROM

    https://community.centminmod.com/threads/csf-to-send-email-notification.7816/#post-33019

    But if you add your email to LF_ALERT_TO then root gets always and all csf-alerts even if you for example add your email to the csf-ignore list.

    In my case i do not want to get an email each time i ssh login OR upload a file. When working on a server file and saving in between i was getting every time an email saying: SSH login alert for user root from 192.xxx.xxx.xx.
    Since i do want to know if somebody else than me achieves to ssh login i do not want to disable this notification.

    While researching for a solution i landed on this thread where @Jimmy suggests replacing the last line of etc/aliases. i.e. replace

    Code:
    # Person who should get root's mail
     #root:        marc
    with

    Code:
     root:  [email protected]
    I am confused because the name of the person who should get root's mail is replaced by an email.

    Once this parameter is changed it seems not possible to change it again. Because when i change the email to something else it doesn't get updated. Maybe it's cached somewhere?!

    And to be honest i am not convinced that this is a solution, because if it is an error then the outcome is in this case that the mail just doesn't get send, right?! So it would be hard to guess a bug when the behaviour is actually like expected.
    ----

    Oh how i would love to see a simple solution during the initial centmin installation and i am imagining this workflow:
    After the step where the server admin gets to put in the information about his primary and secondary email:

    Do you want system mails to be sent via smtp? (no -> moves on with current workflow)
    (yes ->)

    Enter outgoing server:
    Enter username:
    Enter password:
    Enter 'From Name':

    (-> move on with current workflow.)

    ----

    I can think only of positive things resulting out of that simple in between step.
    Starting with thousands if not million of mails not landing in receivers spam folder, tons of servers not getting black-listed, therefor saving energy, saving the environment, saving life! :-p

    I would be very surprised if there isn't already a solution integrated in centminmod for that. But there where also mp3-players...and then the iPod came.
     
    Last edited: Nov 28, 2017
  11. eva2000

    eva2000 Administrator Staff Member

    37,257
    8,139
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +12,531
    Local Time:
    1:29 AM
    Nginx 1.15.x
    MariaDB 5.5/10.x
  12. noly

    noly Member

    93
    13
    8
    Jul 24, 2017
    Germany
    Ratings:
    +25
    Local Time:
    4:29 PM
    1.13.x
    10.x
    It may be that my words weren't chosen very straight to the point while being in the middle of troubleshooting.

    I'd like to point to the current workflow that when setting E-MAIL='[email protected]' in the custom_config.inc, centminmod adds that email to line 625 (LF_ALERT_TO = "") in the etc/csf/csf.conf. Is that intended?

    Which is nice since server admin gets then the csf-alerts sent per mail.
    The downside is like described in my last post that because an email is added to LF_ALERT_TO the admin gets all csf-alerts even if her/his own IP is added to etc/csf/csf.ignore. Adding the admins IP to that ignore list would normally mute alerts associated with that IP.
    But due to LF_ALERT_TO-email the admin gets notifications each time she/he ssh logs in or uploads a file (e.g. working on a server file) saying: SSH login alert for user root from 192.xxx.xxx.xx.

    Thank you for pointing out to the possibility to filter these mails in ones mail client. But getting "less" alert-mails may higher their value when reading them, don't you think?

    Since it is i guess in the interest of the admin if somebody else (another IP) achieves to ssh login, it is from my point of view not an option to just disable the notification.

    Can't centminmod change setup etc/aliases or root/.forward when E-MAIL='[email protected]' is added to the custom_config.inc instead of editing the csf.conf?
     
..