DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 2nd January 2019
apfelgluck apfelgluck is offline
Port Guard
 
Join Date: Sep 2016
Location: France
Posts: 14
Default [OpenSMTPd] Issue with local mails

Hello,


I have a system running OpenBSD 6.4 as a gateway with only two local users : "root" and "foo".
I use the Gmail email service and I do not know how to configure OpenSMTPd as I want :-(

1) I want to be able to send emails to Gmail addresses from local gateway users.
2) I also want emails sent from local gateway users to local gateway users to be delivered not to local mailboxes but to be sent to a Gmail address.

N°1 is OK : it does work from the users "root" and "foo".
Code:
echo "Message" | mail -s "Test" foo.bar@gmail.com

But I don't know how to make it for n°2.

Below are my config files...

Code:
root@145 [17:54:29]:/etc/mail$ cat aliases
root: foo
foo: foo.bar@gmail.com
# The two above lines are the only lines I changed/added.
# (I reloaded the file with newaliases)
Code:
root@145 [17:56:15]:/etc/mail$ cat secrets
aspmx.l.google.com      foo.bar@gmail.com:gmail_account_password
#aspmx.l.google.com is the SMTP server
Code:
root@145 [17:56:18]:/etc/mail$ cat smtpd.conf
########################
# Macros
########################

LOOPBACK="lo0"
LAN_IP="192.168.0.1"

########################
# Listening interfaces
########################

listen on $LOOPBACK
listen on $LAN_IP

########################
# Tables
########################

table aliases file:/etc/mail/aliases
table secrets file:/etc/mail/secrets

########################
# Actions
########################

action "relay" relay host smtp://aspmx.l.google.com auth <secrets>
action "local" mbox alias <aliases>

########################
# Matches
########################

match for any   action "relay"
match for local action "local"

########################
# EOF
########################

Thanks a lot for you assistance.
Reply With Quote
  #2   (View Single Post)  
Old 2nd January 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,983
Default

Unfortunately, smtpd(8) will not revise the recipient in an (e)smtp relay.

I believe .forward files in foo's and root's home directories will provide the appropriate solution. See forward(5).

------------

Here's what I see in your smtpd.conf:

In match statements, "from local" and "for local" are the defaults. Your first match statement:
Code:
match for any   action "relay"
is an implied "from local" and will match Email to any destination that arrived from the TCP socket file or that arrived from a local IP address (local = assigned to a NIC). Your second match statement:
Code:
match for local action "local"
is an implied "from local" and will never match, because the first match will always win.

Your one functional action:
Code:
action "relay" relay host smtp://aspmx.l.google.com auth <secrets>
does not alter the recipient from "foo" to "foo.bar@gmail.com".
  • Aliases are only used for local delivery, and only if you explicitly add them with the alias option.
  • The relay action does not offer you the ability to revise the recipient.
Your listen statements (and defining macros) aren't strictly necessary, as a) you aren't receiving external mail, b) the socket file will be used for local mail transmission, and c) "listen on socket" is an smtpd.conf(5) default.

Last edited by jggimi; 2nd January 2019 at 06:42 PM. Reason: clarity, one thinko
Reply With Quote
  #3   (View Single Post)  
Old 2nd January 2019
apfelgluck apfelgluck is offline
Port Guard
 
Join Date: Sep 2016
Location: France
Posts: 14
Default

Hello jggimi.

Thanks for your quick reply.

I just created the forward file :
Code:
foo@145 [19:41:36]:~$ cat .forward
foo.bar@gmail.com
And it still does not work when foo tries to send an e-mail to himself :
Code:
foo@145 [19:43:34]:~$ echo "Message" | mail -s "Test" foo
Here is the corresponding log :
Code:
root@145 [19:46:30]:/var/log$ cat maillog
[...]
Jan  2 19:34:19 openbsd64 smtpd[64077]: 2b344296073a5b1f smtp connected address=local host=gateway_fqdn
Jan  2 19:34:19 openbsd64 smtpd[64077]: 2b344296073a5b1f smtp message address=local host=gateway_fqdn msgid=ba3a43c3 from=<foo@gateway_fqdn> to=<foo@gateway_fqdn> size=436 ndest=1 proto=ESMTP
Jan  2 19:34:19 openbsd64 smtpd[64077]: 2b344296073a5b1f smtp disconnected address=local host=gateway_fqdn reason=quit
Jan  2 19:34:19 openbsd64 smtpd[64077]: 2b34429a4400522b mta connecting address=smtp://108.177.119.27:25 host=108.177.119.27
Jan  2 19:34:19 openbsd64 smtpd[64077]: 2b34429a4400522b mta connected
Jan  2 19:34:20 openbsd64 smtpd[64077]: 2b34429a4400522b mta starttls ciphers=version=TLSv1.2, cipher=ECDHE-RSA-CHACHA20-POLY1305, bits=256
Jan  2 19:34:20 openbsd64 smtpd[64077]: smtp-out: Server certificate verification succeeded on session 2b34429a4400522b
Jan  2 19:34:20 openbsd64 smtpd[64077]: 2b34429a4400522b mta delivery evpid=ba3a43c39778862f from=<foo@gateway_fqdn> to=<foo@gateway_fqdn> rcpt=<-> source="gateway_internet_IP" relay="108.177.119.27 (108.177.119.27)" delay=1s result="PermFail" stat="550-5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces. Learn more at  https://support.google.com/mail/?p=NoSuchUser f30si8208159edc.18 - gsmtp"
Jan  2 19:34:21 openbsd64 smtpd[64077]: 2b34429be1b2e4fc smtp connected address=local host=gateway_fqdn
Jan  2 19:34:21 openbsd64 smtpd[64077]: 2b34429be1b2e4fc smtp message address=local host=gateway_fqdn msgid=86ef5e22 from=<> to=<foo@gateway_fqdn> size=2139 ndest=1 proto=ESMTP
Jan  2 19:34:21 openbsd64 smtpd[64077]: 2b34429be1b2e4fc smtp disconnected address=local host=gateway_fqdn reason=quit
Jan  2 19:34:21 openbsd64 smtpd[64077]: 2b34429a4400522b mta delivery evpid=86ef5e22e4b40c38 from=<> to=<foo@gateway_fqdn> rcpt=<-> source="gateway_internet_IP" relay="108.177.119.27 (108.177.119.27)" delay=0s result="PermFail" stat="550-5.1.1 The email account that you tried to reach does not exist. Please try double-checking the recipient's email address for typos or unnecessary spaces. Learn more at  https://support.google.com/mail/?p=NoSuchUser f30si8208159edc.18 - gsmtp"
Jan  2 19:34:21 openbsd64 smtpd[30249]: warn: queue: no return path!
Jan  2 19:34:31 openbsd64 smtpd[64077]: 2b34429a4400522b mta disconnected reason=quit messages=0
So it seems that the e-mail is not sent to Gmail with the recipient foo.bar@gmail
Reply With Quote
  #4   (View Single Post)  
Old 2nd January 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,983
Default

If you did not revise your smtpd.conf file, you do not have local delivery and the .forward file or alias table will never be read.
Reply With Quote
  #5   (View Single Post)  
Old 2nd January 2019
apfelgluck apfelgluck is offline
Port Guard
 
Join Date: Sep 2016
Location: France
Posts: 14
Default

Yes, you are right !

The e-mail sent from/to foo/root are now received on the address foo.bar@gmail.com.

The funny thing is that the recipient (showed in the Gmail interface) is still foo@gateway_fqdn (and not foo.bar@gmail.com).

Do you have an idea to fix this ?

If not, I would satisfied with it
Reply With Quote
  #6   (View Single Post)  
Old 2nd January 2019
apfelgluck apfelgluck is offline
Port Guard
 
Join Date: Sep 2016
Location: France
Posts: 14
Default

Issue solved.

Thank to jggimi for his help
Reply With Quote
  #7   (View Single Post)  
Old 2nd January 2019
TronDD TronDD is offline
Spam Deminer
 
Join Date: Sep 2014
Posts: 305
Default

Quote:
Originally Posted by apfelgluck View Post
Yes, you are right !

The e-mail sent from/to foo/root are now received on the address foo.bar@gmail.com.

The funny thing is that the recipient (showed in the Gmail interface) is still foo@gateway_fqdn (and not foo.bar@gmail.com).

Do you have an idea to fix this ?

If not, I would satisfied with it
Look at mail-from under action in smtpd.conf(5)

If you're using mail(1) to send, look at the -r flag.
Reply With Quote
Reply

Tags
open smtp


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenSMTPD gpatrick OpenBSD General 1 23rd February 2011 01:01 AM
send mails with postfix wesley OpenBSD Packages and Ports 1 18th August 2010 07:34 PM
log from rc.conf.local and rc.local sdesilet OpenBSD General 1 21st January 2010 02:37 AM
backup mails on NAS directory milo974 OpenBSD General 3 8th August 2008 07:39 AM
Proper display of accents in mails sent by PERL stukov Programming 5 15th May 2008 04:03 AM


All times are GMT. The time now is 09:01 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick