I found 2 ways of sending mails from Linux/bash :
- through a service , like sSMTP, which implies using an external SMTP server, like gmail
- through Postfix server, which configures the Linux server to act as it's own SMTP server ( I think )
I pretty much found documentation for how to configure each. From what I've seen then are security issues ( which I can't afford since I want to configure this in an IT production environment ) when using a sSMTP service, plus you have to have access to Internet. So this leaves us with Postfix server.
I know how to configure Postfix, except for the domain part. When you first configure this, it asks you for a domain name ( like example.com ). I don't know where to get this. Don't you have to buy a domain ? or should I ask my IT department if they have one so I can use it ? or I can just type anything like domain.com . I want to configure this on a Linux server. On the other hand , I have another Linux server on another network , which has Postfix server configured, so you can send mails , with the following config. file :
cat /etc/postfix/main.cf | grep -v "^#" | grep -v "^$"
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = server2.backup
inet_interfaces = localhost
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = 168*.0/28, 127.0.0.0/8,localhost
relayhost = [10.*]:25
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES I modified the IP adresses with a * for security purposes. What domain was configured here on Postfix ? I just see here localhost.$mydomain, but this doesn't tell me anything. Thank your so much for your patience.
note 1: I found out server 2 uses a relay server in order to send mails, I still don't know what is the domain name it has
91 Answer
I am not completely sure if I correctly understood what you are trying to achieve and what exactly the problem is but for now I'm assuming you want to use Postfix on server2.backup to deliver mail to a mailserver running on putty-server.
You don't need a lot of configuration to achieve this:
# myorigin = <sending domain>
myhostname = server2.backup
relayhost = <putty-server's IP>Set myorigin to whatever domain you want as default in your 'from' email address, e.g. my-personal-domain.com or whitehouse.gov. You can omit it if you want to send from server2.backup.
You need to set relayhost to the IP of putty-server if there is no matching MX record for the domain you are sending mail to. If you want to send mail to multiple servers, check postfix' transport map setting.
That's it. Make sure putty-server accepts mails from server2.backup's ip(-range), e.g. by adding it to mynetworks on putty-server.
If this does not help you, update your question with
- the output of
lsb_release -aorcat /etc/os-release, - the output of
postconf mail_version, - the output of
comm -23 <(postconf -n) <(postconf -d), - relevant log lines from
server2.backup(`/var/log/mail.log) and - relevant log lines from
putty-server.