Centos 7 + sendmail is sending from wrong hostname - centos

I'm stumped: when an email arrives from my server, its from the wrong hostname.
Centos 7
$ postconf -n
....
myhostname = myserver.example.com
....
$ hostname --fqdn
myserver.example.com
$ cat /etc/hosts
123.123.123.123 myserver myserver.example.com
127.0.0.1 localhost
But when receiving an email sent from this host, the From address is different.domain.com
I do see that there is no /etc/mail directory nor /etc/mail/sendmail.cf or /etc/mail/sendmail.mc files.
Ideas, suggestions?
Dan

First you need to check your logs! Is it REALLY Postfix sending the mail or is it a leftover sendmail install?
When Postfix is running: The address used in the sender (envelope and header) is governed by the myorigin parameter. It defaults to:
myorigin = $myhostname
So, it should be "myserver.example.com"

Related

How to configure postfix client on port 465?

I installed postfix on a server, but port 25 was blocked by ISP. I followed http://www.postfix.org/TLS_README.html#client_smtps to configure smtps on port 465.
I follow the configuration as Postfix ≥ 3.0: Sending only mail for a specific destination via SMTPS,
But I have to add mail domain to /etc/postfix/transport.
a.com relay-smtps:mx.a.com:465
b.com relay-smtps:mx.b.com:465
part of /etc/postfix/main.cf:
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_scache
smtp_tls_security_level = may
tls_random_source = dev:/dev/urandom
smtp_tls_loglevel = 1
transport_maps = hash:/etc/postfix/transport
part of /etc/postfix/master.cf:
relay-smtps unix - - n - - smtp
# Client-side SMTPS requires "encrypt" or stronger.
-o smtp_tls_security_level=encrypt
-o smtp_tls_wrappermode=yes
For destination not in transport, postfix tries connect to port 25.
I can only send email to destination listed in transport.
How do I change the postfix so that it tries send all emails to [their own DNS MX record]:465 ?
I have tried Postfix ≥ 3.0: Sending all remote mail to an SMTPS server:
relayhost = [mx.a.com]:465
But it was regarded as spam.
If I do like:
mydomain.com :
* relay-smtps:how can use DNS MX recode auto:465
How can I specify port 465 and use DNS MX record?
Thanks!

exim Timing Out to Gmail

I have a Centos server with exim installed. I am trying to send en email from the command line like this:
exim -v account#gmail.com
From: email#mydomain.com
To: account#gmail.com
Subject: test email
this is a test
^D
I have also tried:
echo 'test message' | mail -s Test1 account#gmail.com
as well as sending from a PHP script.
The result is the email times out. The logs indicate exim is timing out:
H=alt2.gmail-smtp-in.l.google.com [173.194.219.26] Connection timed out
I believe iptables are correct. I have scanned the server from an external IP and ports 25, 265 and 587 are open. (Not sure 587 needs to be since this will be a send-only situation most likely.)
I have also telnet'd to port 25 successfully. (Most of the successful resolutions I have found involved port 25 being blocked. I don't think that is the case here. I have also called my provider and checked. They claim port 25 connections are not blocked.)
I would appreciate some ideas.
Thank you.

Trying to set up Catch-All Email Address with Sendmail

I'm trying to create a catchall email address with Sendmail (it will be used to catch email bounces for Oceth's OEMPro).
First I started by creating a new user:
# useradd -s /bin/false bounces
# passwd bounces
Then I created & opened a virtusertable file with vim virtusertable and added:
bounces#sub.example.com bounces
#sub.example.com bounces#sub.example.com
Then I added the below line to sendmail.mc near the end but before the MAILER_DEFINITIONS of with
FEATURE(`virtusertable', `hash -o /etc/mail/virtusertable.db')dnl
Finally, I ran
# make
Updating databases ...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/databases...
Updating auth ...
sasl2-bin not installed, not configuring sendmail support.
To enable sendmail SASL2 support at a later date, invoke "/usr/share/sendmail/update_auth"
Creating /etc/mail/relay-domains
# Optional file...
Updating Makefile ...
Reading configuration from /etc/mail/sendmail.conf.
Validating configuration.
Creating /etc/mail/Makefile...
Updating sendmail.cf ...
The following file(s) have changed:
/etc/mail/sendmail.cf
** ** You should issue `/etc/init.d/sendmail reload` ** **
# service sendmail reload
* Reloading Mail Transport Agent (MTA) sendmail [ OK ]
# service sendmail restart
* Restarting Mail Transport Agent (MTA) sendmail [ OK ]
After all this it does not seem to be working, how can I test this properly. I've tried sending an email to bounces#sub.example.com but when I look in /var/mail/ I don't see the bounces user.
# ls /var/mail/
root www-data other-user
I created a MX DNS record for this too, e.g. sub.example.com.
The other indication it is not working correctly is that we are getting a 504 error when we try to use this email address as our POP3 Monitoring method in Oceth's OEMPro.
UPDATE
I tried running the below commands as root, in an attempt to debug the issue but I'm not clear what it's telling me.
root:/# sendmail -d60.5 -bv no-such-user#sub.example.com
map_lookup(dequote, other-user, %0=other-user) => NOT FOUND (0)
map_lookup(host, sub.example.com, %0=sub.example.com) => sub.example.com. (0)
no-such-user#sub.example.com... deliverable: mailer esmtp, host sub.example.com., user no-such-user#sub.example.com
root:/# sendmail -d60.5 -bv bounces#sub.example.com
map_lookup(dequote, other-user, %0=other-user) => NOT FOUND (0)
map_lookup(host, sub.example.com, %0=sub.example.com) => sub.example.com. (0)
bounces#sub.example.com... deliverable: mailer esmtp, host sub.example.com., user bounces#sub.example.com
I'm not sure why it first tries to look up another user on our system called other-user
UPDATE 2
After running # echo '$=w' | sendmail -bt I get the following result.
# echo '$=w' | sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> localhost
ip-1??-??-??-??5
[1??.??.??.??5]
ip-1??-??-??-??5.ec2.internal
[127.0.0.1]
ip-172-31-31-167.eu-west-1.compute.internal
In sendmail.mc I've changed FEATURE(virtusertable', hash -o /etc/mail/virtusertable.db')dnl to FEATURE(virtusertable', hash -o /etc/mail/virtusertable.db')dnl, basically I just removed the -o flag.
Then I updated /etc/mail/local-host-names to include sub.example.com, so now it reads:
localhost
ip-17?-??-??-?67.eu-west-1.compute.internal
sub.example.com
Then I ran:
# service sendmail restart
* Restarting Mail Transport Agent (MTA) sendmail
# echo '$=w' | sendmail -bt
ADDRESS TEST MODE (ruleset 3 NOT automatically invoked)
Enter <ruleset> <address>
> localhost
ip-1??-??-??-??5
[1??.??.??.??5]
ip-1??-??-??-??5.ec2.internal
[127.0.0.1]
sub.example.com
ip-17?-??-??-?67.eu-west-1.compute.internal
After sending an email to bunces#sub.example.com I still don't see the mailbox in /var/mail/
# ls /var/mail/
root www-data other-user
I also still get the 504 error in the OEMPro app when I try to configure it with these settings.
Sendmail consults virtusertable only for deliveries to local email domains (listed in $=w) and virtual domains (listed in $={VirtHost}). It seems that sub.example.com is not listed in any of them.
You can add sub.example.com to list of local email domains by listing it in file /etc/mail/local-host-names (one domain/name per line). After modifying the file restart sendmail daemon or send HUP signal to sendmail daemon.
You can check content of $=w by executing the following command as root:
echo '$=w' | sendmail -bt
Sendmail by default automagically adds some "guesswork" to $=w.
Extra hint:
Do not use -o (optional) flag in FEATURE(virtusertable). Without the flag sendmail refuses to start when compiled version of virtusertable is unawailable.

exim4 cannot send email to root (all localhost users)

I have a problem with exim4 configuration. I try to send email to root, but email stay frozen in queue.
I tried this:
root#server2:~# echo TEST | mail -s "Hello this is testing email" root
and email is in queue (frozen), please see some outputs below.
In log (/var/log/exim4/mainlog) is this message:
2014-06-11 11:47:36 1Wuf84-0004o3-E4 <= root#server2.mydomain.cz U=root P=local S=416
2014-06-11 11:47:36 1Wuf84-0004o3-E4 remote host address is the local host: server2.mydomain.cz
2014-06-11 11:47:36 1Wuf84-0004o3-E4 == mailer-daemon#server2.mydomain.cz R=dnslookup defer (-1): **remote host address is the local host**
2014-06-11 11:47:36 1Wuf84-0004o3-E4 Frozen
Local host is routable (I hope):
root#server2:~# exim -bt localhost
LOG: MAIN
remote host address is the local host: server2.danielblazek.cz (while routing <localhost#server2.mydomain.cz>)
localhost#server2.mydomain.cz cannot be resolved at this time: remote host address is the local host
root#server2:~#
Configuration of hostname is right:
root#server2:~# hostname && hostname -f
server2
server2.mydomain.cz
Aliases seems to be OK:
root#server2:~# cat /etc/aliases
# /etc/aliases
mailer-daemon: postmaster
postmaster: root
nobody: root
hostmaster: root
usenet: root
news: root
webmaster: root
www: root
ftp: root
abuse: root
noc: root
security: root
root: root
clamav: root
Do have any idea how can I fix it? With Postfix I never have problem like that. System emails always was delivered to /var/mail folder. But with exim4 I' m on the rocks. It's required for me receive system emails...
Please ask me if you need more information or outputs. Thank you for all replies!
Daniel
remote host address is the local host is an exim error message which indicates that the sender or recipient's domain has your machine's hostname/IP, but exim is not configured to accept mail for that domain.
Exim has a standard domainlist named +local_domains that pretty much every different exim configuration system uses. See what domains are configured for your system by running:
exim -bP '+local_domains'
You will probably see a command that looks up a list of domains from a file. Put your hostname (in this case, it looks like it's an implicit hostname "localhost") in that file and exim should begin to work properly. Your test was slightly incorrect; you must pass the username you are delivering to, not the hostname:
exim -bt root

How configure roundcube to work with imaps?

I recently installed Postfix, Dovecot to setup a mail server on my own VPS ( using this tutorial: Email with Postfix, Dovecot, Mysql)
Imaps server uses port 993 for Authentication, and Postfix uses port 25 to send mails.
In this tutorial, users stored in a Database ( so imaps use mysql to authenticate users).
i'm sure every thing works fine with imaps and postfix , because few days ago i installed Kmail client (on my linux) and receive mails from my server. sending mails also works fine, i sent a mail to Gmail and google received it without a problem (in my "Gmail inbox" not spam folder)
So to get to my Emails from a web mail client, i installed Roundcube on /var/www/mail directory.
I configured Roundcube many times. but each time it gives me this Error:
IMAP Error: Login failed for [me#mydomain] from X.x.X.x . Empty
startup greeting (localhost:993) in
/var/www/mm/program/lib/Roundcube/rcube_imap.php on line 184 (POST
/mm/?_task=login?_task=login&_action=login)
When i do log in from roundcube, imap server says ( in /var/log/mail.log ):
May 20 07:05:16 my-server dovecot: imap-login: Disconnected (no auth
attempts): rip=::1, lip=::1, TLS handshaking: Disconnected
Here is my roundcube config file :
$config['db_dsnw'] = 'mysql://roundcubeuser:myPassword#localhost/roundcubemail';
// ----------------------------------
// IMAP
// ----------------------------------
$config['debug_level'] = 13;
$config['default_host'] = 'ssl://127.0.0.1';
$config['default_port'] = 993;
// ----------------------------------
// SMTP
// ----------------------------------
$config['smtp_server'] = 'ssl://localhost';
What's the problem? i really have no idea what is happening !
Thank you.
I'm using postfix + dovecot + roundcube a few months now and it's working for me. In my configuration, postfix rejects plaintext sessions, so roundcube has to connect with ssl - and it's working.
This is from my main.inc.php. I don't remember editing anything here, it's just the initial config created during the installation.
Now that I'm looking at it, default_port doesn't make any sense, I think it's just ignored.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - http hostname ($_SERVER['SERVER_NAME'])
// %d - domain (http hostname without the first part)
// %s - domain name after the '#' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %d = domain.tld
// TCP port used for IMAP connections
$rcmail_config['default_port'] = 143;
$rcmail_config['default_host'] = array("ssl://localhost:993");
// TCP port used for IMAP connections
$rcmail_config['default_port'] = 143;
In case the other answer does not work, this is what worked for me. My config.inc.php now contains:
$config['default_host'] = 'ssl://localhost';
$config['default_port'] = 993;
NOTE: using tls://localhost did not work for me. I had to specify ssl:// as the URI scheme.
Via PhpMyAdmin, I also ran this SQL command (all my user accounts are on the same machine that runs RoundCube):
UPDATE `rc_users` SET `mail_host`='ssl://localhost'
I got the port number 993 from running sudo netstat -tulnp in order to determine the port on which Dovecot was listening.