Learn about Centmin Mod LEMP Stack today
Become a Member

Email root email forward

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

  1. ahmed

    ahmed Active Member

    361
    49
    28
    Feb 21, 2017
    Ratings:
    +63
    Local Time:
    3:10 AM
    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:
    10:10 PM
    1.11.13
    Yes 25! It's possible to send this e-mails from centminmod with transactional emails server? Like SparkPost, Mandrill, Sendgrid?
     
  3. ahmed

    ahmed Active Member

    361
    49
    28
    Feb 21, 2017
    Ratings:
    +63
    Local Time:
    3:10 AM
    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:
    10:10 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:
    10:10 PM
    1.11.13
  6. eva2000

    eva2000 Administrator Staff Member

    55,802
    12,272
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,858
    Local Time:
    11:10 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    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

    55,802
    12,272
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,858
    Local Time:
    11:10 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    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

    106
    16
    18
    Jul 24, 2017
    Germany
    Ratings:
    +28
    Local Time:
    3:10 AM
    1.18.x
    10.2.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='my@mail.com'
    to the custom_config.inc

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

    eva2000 Administrator Staff Member

    55,802
    12,272
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,858
    Local Time:
    11:10 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    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 root@yourhostnamecom sent system emails.
     
  10. noly

    noly Member

    106
    16
    18
    Jul 24, 2017
    Germany
    Ratings:
    +28
    Local Time:
    3:10 AM
    1.18.x
    10.2.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@domain.com
    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

    55,802
    12,272
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,858
    Local Time:
    11:10 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  12. noly

    noly Member

    106
    16
    18
    Jul 24, 2017
    Germany
    Ratings:
    +28
    Local Time:
    3:10 AM
    1.18.x
    10.2.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='mail@email.com' 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='xxx@xxx.xxx' is added to the custom_config.inc instead of editing the csf.conf?
     
  13. Trung

    Trung New Member

    4
    0
    1
    Dec 2, 2019
    Ratings:
    +0
    Local Time:
    8:10 AM
    1.7.16
    MariaDB 10
    Hi,

    I have a problem with setting up root user email. The email deliver to my registered email address by root user (which is emails about log information like log in/out SSH, IP blocked, etc.) doesn't sent by a domain email like root@mydomain.com, or root@hostname.domain.com. But sent by root@hostname.localdomain. So it always goes into spam box.

    The email sent by Wordpress is properly from Wordpress@mydomain.com, therefore it always goes in to my inbox.

    How can I fix this problem? Thanks!
     
  14. eva2000

    eva2000 Administrator Staff Member

    55,802
    12,272
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,858
    Local Time:
    11:10 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Sounds like you didn't setup your server's main hostname properly as per Getting Started Guide step 1 outlined at https://centminmod.com/getstarted.html
     
  15. Trung

    Trung New Member

    4
    0
    1
    Dec 2, 2019
    Ratings:
    +0
    Local Time:
    8:10 AM
    1.7.16
    MariaDB 10
    Ah, my bad. Thank you!