Solved! OSSEC error with sending mail to gmail account
os_sendmail(1767): WARN: End of DATA not accepted by server
ossec-maild(1223): ERROR: Error Sending email to 74.125.141.27 (smtp server)
I've done some research, but not sure how to fix the issue.
12 Replies
I would do what they did and tcpdump the connection to see the error response. You'll probably get something similar to what they got. If so, I would set up a local send-only mailserver, make sure you've set your rDNS correctly, and set up SPF. (If you're feeling crazy, you could set up DKIM too, but that's a fair bit more work, and not absolutely necessary.) The following guide covers a basic send-only Exim setup which would work for this purpose:
If you're using Debian instead of Ubuntu, ignore the step about editing /etc/apt/sources.list.
So I went through Linode's document on setting up postfix for Gmail with my own domain, but I'm getting a "can't deliver mail" when doing the echo test. Link:
I tried the first two name servers just in case that was causing an issue, the email address is spelled right, and I setup an app specific password because I use two factor authentication.
The error in the email is: Note: I changed the domain name to example.
Final-Recipient: rfc822;
Action: failed
Status: 5.1.1
Diagnostic-Code: X-Postfix; unknown user: "emailjim"
smtpdrelayrestrictionssmtpdrecipientrestrictions
Thanks for following up. I'm getting at least some level 2 emails, but certainly not all.
Output of postconf -n is the following: Note. I did change the actual host name to "name-of-host"
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
appenddotmydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailboxsizelimit = 0
mydestination = gmail.com, name-of-host, localhost.localdomain, localhost
myhostname = gmail.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = [smtp.gmail.com]:587
smtpsaslauth_enable = yes
smtpsaslpasswordmaps = hash:/etc/postfix/saslpasswd
smtpsaslsecurity_options = noanonymous
smtptlsCAfile = /etc/ssl/certs/ca-certificates.crt
smtptlssessioncachedatabase = btree:${datadirectory}/smtpscache
smtpusetls = yes
smtpdbanner = $myhostname ESMTP $mailname (Debian/GNU)
smtpdrelayrestrictions = permitmynetworks permitsaslauthenticated deferunauth_destination
smtpdtlscert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpdtlskey_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpdtlssessioncachedatabase = btree:${datadirectory}/smtpdscache
smtpdusetls = yes
Does your /etc/aliases contain an entry for emailjim? Have you run newaliases to generate the db file?
I removed the gmail.com from the host name list, restarted postfixt, and then did a echo test email. The email went through right away! So then I setup OSSEC to send alerts to my main gmail account instead of the emaijim address. I restarted OSSEC, but I'm still getting error that it can't send the email. I made sure both to and from email addresses are the same and the smtp server is smtp.gmail.com
You can have emailjim aliased to root, but then root should be aliased to an address that Gmail can deliver to, e.g.
root: foo@example.com
Huge thanks for taking the time to figure out the problem(s) and pointing out the mistakes! I owe you a beer (or more) for that. Between the Linode OSSEC guide, the postfix guide, and this thread, I'll have to compare things and make notes of the changes needed.