I'm trying to set up multiple email accounts on mailx (one from gmail and one from office365). When I had just one it worked fine but if I try to add another, mailx will always use the SMTP details from the last defined server regardless of what email I choose using -r. Is there a way to add multiple accounts to send from? Couldn't find anything useful off Google.
Below is the end of my /etc/mail.rc file (running on Centos 7).
set bsdcompat
set smtp=smtps://smtp.gmail.com:465
set smtp-auth=login
set smtp-auth-user=EMAIL1@gmail.com
set smtp-auth-password=PASSWORD1
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
set bsdcompat
set smtp=smtp.office365.com:587
set smtp-use-starttls
set smtp-auth=login
set smtp-auth-user=EMAIL2@office.com
set smtp-auth-password=PASSWORD2
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
Thanks in advance
For anyone having this problem, after reading through the man page for mailx I found the account function:
account account1 {
set smtp=smtps://smtp.gmail.com:465
set smtp-auth=login
set smtp-auth-user=EMAIL1@gmail.com
set smtp-auth-password=PASSWORD1
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
}
account account2 {
set smtp=smtp.office365.com:587
set smtp-use-starttls
set smtp-auth=login
set smtp-auth-user=EMAIL2@office.com
set smtp-auth-password=PASSWORD2
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/
}