Send a test mail using Telnet
Emulating an SMTP session with Telnet
Let us try to send an email to the user now. As the "example.com" domain does not really existing your DNS settings will likely not point to the right server. So we are simulating an SMTP session with the telnet command. Install the telnet package if you haven't already:
$> aptitude install telnet
Then establish a TCP connection to the SMTP port:
$> telnet localhost smtp
The server should reply:
Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 mailtest ESMTP Postfix (Debian/GNU)
Great. Postfix is listening and wants us to speak SMTP. First we need to be friendly:
ehlo example.com
Postfix appreciates our friendliness and tells us which features it provides:
250-my-new-mailserver 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN
Hey, Postfix, we have a mail from steve@example.com:
mail from:<steve@example.com>
Looks like Postfix is happy with that because return codes that start with a '2' are good news:
250 2.1.0 Ok
Tell Postfix who the recipient of the mail is:
rcpt to:<john@example.com>
Postfix accepts that:
250 2.1.5 Ok
Then we are ready to send the actual mail:
data
Postfix agrees and tells us we can send the actual mail now and end our input with a dot on an empty line:
354 End data with <CR><LF>.<CR><LF>
Okay, type in the mail:
Hi John,
just wanted to drop you a note.
.
Postfix tells us it has received the mail and queued under a queue ID:
250 2.0.0 Ok: queued as A9D64379C4
Thanks, Postfix, we are done:
quit
Checking the logs
Take a look at the /var/log/mail.log file now. You should see something similar to:
postfix/smtpd[...]: connect from localhost[127.0.0.1] postfix/smtpd[...]: 5FF712A6: client=localhost[127.0.0.1] postfix/cleanup[...]: 5FF712A6: message-id=<...> postfix/qmgr[...]: 5FF712A6: from=<steve@example.com>, size=364, nrcpt=1 (queue active) postfix/pipe[...]: 5FF712A6: to=<john@example.com>, relay=dovecot, ..., status=sent (delivered via dovecot service) postfix/qmgr[...]: 5FF712A6: removed postfix/smtpd[...]: disconnect from localhost[127.0.0.1]
The delivery has worked. Postfix has correctly determined that the destination domain is a virtual domain and forwarded the email to the 'dovecot' service.
Checking the user's mailbox
The email should now be somewhere under /var/vmail/example.com/john. Let us take a look:
$> cd /var/vmail/example.com/john/Maildir $> find . ./cur ./new ./new/1179521979.V801I2bbf7M15352.mailtest ./tmp
There sits the email. Try to read the mail with the "mutt" program:
$> mutt -f .
The new email is shown:
q:Quit d:Del u:Undel s:Save m:Mail r:Reply g:Group ?:Help 1 N May 18 steve@example.c (0.1K)
Press ENTER to read the email:
From: steve@example.com To: undisclosed-recipients: ; Hi John, just wanted to drop you a note.
So the email arrived at John's account. Perfect. Choose 'q' twice to exit mutt again.
Comments
Fatal: Missing destination argument
Hi, ich hänge beim Versenden der Testmail fest.
Im Log steht:
Aug 9 17:57:35 mail postfix/pipe[7184]: F28071C28258: to=<info@domain.de>, relay=dovecot, delay=98, delays=98/0.03/0/0.03, dsn=5.3.0, status=bounced (command line usage error. Command output: Fatal: Missing destination argument )
Wer hat eine Tipp für mich?
Stephan
Double check your
Double check your /etc/postfix/master.cf - sounds like your "dovecot" entry is broken.
Danke, das war der erste
Danke, das war der erste Fehler ;)
ich hatte nur ein } vergessen...
Ok, jetzt steht im Log:
Aug 9 19:09:20 mail dovecot: auth-worker(default): sql(postmaster@domain.de): User query failed: Table 'mailserver.users' doesn't exist
Ich habe alles nochmal durchgeschaut, kann aber in keiner Datei den Fehler finden, vielleicht brauche ich noch nen Kaffee :P
Stephan
Läuft alles
Moin,
ok, alles noch mal von vorne und jetzt läuft es Fehlerfrei, vielen Dank für das hervorragende Tutorial !
Gruß Stephan
Cannot telnet to smtp
Hello!
I'm trying to telnet to localhost smtp but it refuses me saying:
Trying 127.0.0.1...
Trying ::1...
telnet: Unable to connect to remote host: Connection refused
Any idea why is it doing this?
PS: It can connect to http.
Cannot telnet to smtp
I solved it.
I looked at /var/log/mail.err and it said:
postfix/master[2612]: fatal: /etc/postfix/master.cf: line 67: bad transport type: user=vmail
So, I needed to correct the master.cf file.
Cannot telnet POP3
Hi
I have more or less the same problem but I can telnet smtp with no problems but when I try using pop3. I get connection refused.
Thanks
My first problem...
I've got a problem in this step. When I'm trying to make a smtp test my messages are been saved in the /var/mail directory... Part of my log: Sep 2 21:35:23 r21389 postfix/postfix-script[9941]: refreshing the Postfix mail system Sep 2 21:35:23 r21389 postfix/master[26943]: reload configuration /etc/postfix Sep 2 21:35:33 r21389 postfix/smtpd[9956]: connect from localhost.localdomain[127.0.0.1] Sep 2 21:36:15 r21389 postfix/trivial-rewrite[9992]: warning: do not list domain kkapron.com in BOTH mydestination and virtual_mailbox_domains Sep 2 21:36:15 r21389 postfix/smtpd[9956]: 5833817957: client=localhost.localdomain[127.0.0.1] Sep 2 21:36:21 r21389 postfix/cleanup[9993]: 5833817957: message-id=<20090902193615.5833817957@r21389.ovh.net> Sep 2 21:36:22 r21389 postfix/qmgr[9945]: 5833817957: from=
See the warning
The warning you quoted is exactly the cause or your trouble:
Thanks
You're right, I made some change and it works :) Now I'm going to make next step :)
same problem
hello,
i have the same problem and i can't solve it. what is the problem? how can i solve it?
Deferred
Hello:
I went through all the steps and I am able to send the mail, but the log says:
relay=dovecot, delay=46, delays=46/0.01/0/0.01, dsn=4.3.0, status=deferred (temporary failure)
Restarting the daemons do not help. And the mailbox at /var/vmail are not created.
any help?
Regards
Jesus
"the mailbox at /var/vmail
"the mailbox at /var/vmail are not created."
I have the same problem. dovecot won't create the directories. Any help?
Permissions?
Please check that /var/vmail is writeable by the "vmail" user.
Dec 10 01:36:31 xXXx
Dec 10 01:36:31 xXXx deliver(xXx@xXx.com): postmaster_address setting not given
was könnte das sein ? hab schon alles abgesucht aber komme nicht drauf
dovecot.conf
Check your dovecot.conf...
Irgendwas hat nicht geklappt
irgendeine Idee? Der Mailserver heißt mail.meineTld.de, meineTld.de ist ebenfalls in den Virtual Domains eingetragen..
status=bounced (mail for meineTld.de loops back to myself)
'Mail loops back to myself'
'Mail loops back to myself' means that your Postfix wanted to send out the mail to the internet but then discovered that the DNS says your mail server should be responsible. Most likely you forgot to list your domain in mydestination or virtual_(alias|mailbox)_domains
MySQL connection
Dear Christoph, I'm following your tutorial and I get the following error messages when I try send the test mail. ehlo works, but nothing else. Feb 6 23:13:37 linode postfix/trivial-rewrite[6300]: warning: connect to mysql server localhost: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Feb 6 23:13:37 linode postfix/trivial-rewrite[6300]: fatal: mysql:/etc/postfix/mysql-virtual-alias-maps.cf(0,lock|fold_fix): table lookup problem In the previous step where we checked the postfix config with postmap I get no errors: postmap -q john@example.com mysql:/etc/postfix/mysql-virtual-alias-maps.cf john@example.com,devnull@workaround.org What could it be? Thank you for your time.
127.0.0.1
Hi. You will probably solve your issue by using "127.0.0.1" as your database server where you seemed to have used "localhost". That may sound strange but for Postfix it really makes a difference. "localhost" means to use a (UNIX) socket connection and that would mean you need a MySQL socket within the /var/spool/postfix directory where Postfix is jailed into for security reasons. If you use "127.0.0.1" instead then Postfix will do a TCP connection instead which is not limited by the jail.
That is the weird thing
I thought that would be the problem too. But the configuration file uses 127.0.0.1:
and the postmap test works as well... Wel thanks again for looking.
I found it
I was stupid. While reading the postfix manual I saw you had to define "hosts". It is working absolutely fine now!
Thanks again
status=deferred (connect to mx.workaround.org[85.214.93.191]:25:
hostname
ubuntu.gohelp.in
$ hostname -f
ubuntu.gohelp.in
$ cat /etc/hostname
ubuntu.gohelp.in
$ cat /etc/hosts
hosts hosts.allow hosts.deny
$ cat /etc/hosts
hosts hosts.allow hosts.deny
$ cat /etc/hosts
127.0.0.1 localhost
202.164.58.218 ubuntu.gohelp.in ubuntu gohelp.in
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
mail.log
Jan 2 03:38:07 ubuntu postfix/cleanup[5192]: E0CA18B6C5: message-id=<20020101220745.E0CA18B6C5@ubuntu.gohelp.in>
Jan 2 03:38:07 ubuntu postfix/qmgr[3265]: E0CA18B6C5: from=<1@eultimateinc.com>, size=375, nrcpt=1 (queue active)
Jan 2 03:38:18 ubuntu postfix/smtpd[5137]: disconnect from ubuntu.gohelp.in[202.164.58.218]
Jan 2 03:38:38 ubuntu postfix/smtp[5153]: connect to mx.workaround.org[85.214.93.191]:25: Connection timed out
Jan 2 03:38:38 ubuntu postfix/smtp[5153]: E0CA18B6C5: to=<devnull@workaround.org>, relay=none, delay=81, delays=50/0/31/0, dsn=4.4.1, status=deferred (connect to mx.workaround.org[85.214.93.191]:25: Connection timed out)
Old?
Wow, a log file from two months ago? :) At the beginning of the year I had a lot of trouble with my ISP. So during that time it might well have happened that mx.workaround.org was unreachable. What's your point anyway?
Christoph
Connection timed out
Feb 25 00:32:33 ubuntu postfix/cleanup[19202]: 9DA51E0C2: message-id=<20100224190218.9DA51E0C2@ubuntu.gohelp.in>
Feb 25 00:32:33 ubuntu postfix/qmgr[3443]: 9DA51E0C2: from=<sales@eultimateinc.com>, size=379, nrcpt=1 (queue active)
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: public/cleanup socket: wanted attribute: status
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: input attribute name: status
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: input attribute value: 0
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: public/cleanup socket: wanted attribute: reason
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: input attribute name: reason
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: input attribute value: (end)
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: public/cleanup socket: wanted attribute: (list terminator)
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: input attribute name: (end)
Feb 25 00:32:33 ubuntu postfix/smtpd[19196]: > ubuntu.gohelp.in[202.164.58.218]: 250 2.0.0 Ok: queued as 9DA51E0C2
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: < ubuntu.gohelp.in[202.164.58.218]: quit
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: > ubuntu.gohelp.in[202.164.58.218]: 221 2.0.0 Bye
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: match_hostname: ubuntu.gohelp.in ~? 127.0.0.0/8
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: match_hostaddr: 202.164.58.218 ~? 127.0.0.0/8
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: match_hostname: ubuntu.gohelp.in ~? 202.164.58.128/25
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: match_hostaddr: 202.164.58.218 ~? 202.164.58.128/25
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: disconnect from ubuntu.gohelp.in[202.164.58.218]
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: master_notify: status 1
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: connection closed
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: auto_clnt_close: disconnect private/tlsmgr stream
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: rewrite stream disconnect
Feb 25 00:32:34 ubuntu postfix/smtpd[19196]: proxymap stream disconnect
Feb 25 00:32:38 ubuntu postfix/anvil[18954]: statistics: max connection rate 2/60s for (smtp:83.142.52.242) at Feb 25 00:29:17
Feb 25 00:32:38 ubuntu postfix/anvil[18954]: statistics: max connection count 1 for (smtp:124.253.36.36) at Feb 25 00:26:15
Feb 25 00:32:38 ubuntu postfix/anvil[18954]: statistics: max cache size 1 at Feb 25 00:26:15
Feb 25 00:32:44 ubuntu postfix/smtpd[19208]: connect from localhost[127.0.0.1]
Feb 25 00:32:44 ubuntu postfix/smtpd[19208]: CBB82E15B: client=localhost[127.0.0.1]
Feb 25 00:32:44 ubuntu postfix/cleanup[19202]: CBB82E15B: message-id=<20100224190218.9DA51E0C2@ubuntu.gohelp.in>
Feb 25 00:32:44 ubuntu postfix/qmgr[3443]: CBB82E15B: from=<sales@eultimateinc.com>, size=830, nrcpt=1 (queue active)
Feb 25 00:32:44 ubuntu postfix/smtpd[19208]: disconnect from localhost[127.0.0.1]
Feb 25 00:32:44 ubuntu amavis[2923]: (02923-04) Passed CLEAN, [202.164.58.218] [202.164.58.218] <sales@eultimateinc.com> -> <devnull@workaround.org>, Message-ID: <20100224190218.9DA51E0C2@ubuntu.gohelp.in>, mail_id: sFyeHtoWDF4I, Hits: 1.284, size: 379, queued_as: CBB82E15B, 11160 ms
Feb 25 00:32:44 ubuntu postfix/smtp[19203]: 9DA51E0C2: to=<devnull@workaround.org>, relay=127.0.0.1[127.0.0.1]:10024, delay=50, delays=39/0.01/0.01/11, dsn=2.0.0, status=sent (250 2.0.0 Ok, id=02923-04, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as CBB82E15B)
Feb 25 00:32:44 ubuntu postfix/qmgr[3443]: 9DA51E0C2: removed
Feb 25 00:33:15 ubuntu postfix/smtp[19211]: connect to mx.workaround.org[85.214.93.191]:25: Connection timed out
Feb 25 00:33:15 ubuntu postfix/smtp[19211]: CBB82E15B: to=<devnull@workaround.org>, relay=none, delay=31, delays=0.04/0.02/31/0, dsn=4.4.1, status=deferred (connect to mx.workaround.org[85.214.93.191]:25: Connection timed out)
Will u please help ?
Provider restrictions?
Could it be that your internet provider does not allow SMTP connections from their clients? That a pretty common problem. Check whether "telnet mx.workaround.org 25" goes through. If it doesn't then chances are that your ISP is very restrictive. Check with them how you are supposed to send out emails. They probably offer a relay server that you can set as "relayhost" in your main.cf.
I am unable to telnet on
I am unable to telnet on mx.workaround.org , but i called up my ISP
and asked they said we already unlocked your 25 port. You can check telnet smtp.gmail.com 465.
now can u please resolve this?
465?
465 is the TCP port for secure (SSL) SMTP. What about port 25? Can you "telnet mx.workaround.org 25"? If now... complain to your ISP again. The error is not in your configuration.
mailbox for steve created?
I tried the test, everything went fine.
But (theres always a but..)
mail for devnull@workaround.org is bounced for some reason (rdns is wrong) and now dovecot (?) creates a maildir for steve@example.com.
The mailserver probably thinks he is responsible for example.com but i don't get why he is creating a maildir for a (not in mailbox maps) non existent user.
Is this expected behavior? In this case i belive bounced mail with an (non existent) mail from (with a virtual_alias_domain as domain part) is delivered to a new maildir.
Mail from external can't be send to steve@example.com, but a bounce because of an alias does (if the sender was steve@example.com)
virtual_mailbox_maps?
If Dovecot creates mailboxes for random non-existing users then I could imagine your virtual_mailbox_maps settings is incorrect. Check it: "postconf virtual_mailbox_maps"
# postconf
# postconf virtual_mailbox_maps
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
# cat /etc/postfix/mysql-virtual-mailbox-maps.cf
user = mailuser
password = PASS
hosts = 127.0.0.1
dbname = DB
query = SELECT 1 FROM virtual_users WHERE email='%s'
It does not creat4e random accounts, but only in the described example: an destination recipient that is configured for an alias bounced AND the sender has the domainpart of the server but is non existent
Can you try:
- Setup an Alias, with an external traget that is non existent and will bounce (actually something that rejects with a 5XX when trying to deliver)
- telnet to your mailserver
ehlo server
mail from:<NONexistentuser@mailserver>
rcpt to:<aliasuserwith bouncing destination>
data
test
.
.
Some logfiles from me (using just the entries of your howto, spammer is no local user, but gets created a maildir after bounce):
Feb 27 18:01:40 svrNEU postfix/smtpd[11910]: connect from localhost[127.0.0.1]
Feb 27 18:01:40 svrNEU postfix/smtpd[11910]: 6D3A920DA287: client=localhost[127.0.0.1]
Feb 27 18:01:40 svrNEU postfix/cleanup[11906]: 6D3A920DA287: message-id=<20100227170128.5455C20DA284@svrNEU.de.de>
Feb 27 18:01:40 svrNEU postfix/qmgr[11899]: 6D3A920DA287: from=<spammer@example.com>, size=1093, nrcpt=2 (queue active)
Feb 27 18:01:40 svrNEU amavis[11746]: (11746-01) Passed CLEAN, LOCAL [127.0.0.1] [127.0.0.1] <spammer@example.com> -> <john@example.com>, Message-ID: <20100227170128.5455C20DA284@svrNEU.de.de>, mail_id: KQdP9epsxras, Hits: 3.732, size: 415, queued_as: 6D3A920DA287, 312 ms
Feb 27 18:01:40 svrNEU postfix/smtp[11907]: 5455C20DA284: to=<john@example.com>, relay=127.0.0.1[127.0.0.1]:10024, delay=15, delays=15/0/0.01/0.31, dsn=2.0.0, status=sent (250 2.0.0 Ok, id=11746-01, from MTA([127.0.0.1]:10025): 250 2.0.0 Ok: queued as 6D3A920DA287)
Feb 27 18:01:40 svrNEU postfix/pipe[11912]: 6D3A920DA287: to=<john@example.com>, relay=dovecot, delay=0.02, delays=0.01/0.01/0/0.01, dsn=2.0.0, status=sent (delivered via dovecot service)
Feb 27 18:01:40 svrNEU postfix/qmgr[11899]: 5455C20DA284: removed
Feb 27 18:01:41 svrNEU postfix/smtp[11911]: 6D3A920DA287: to=<devnull@workaround.org>, orig_to=<john@example.com>, relay=mx.workaround.org[85.214.93.191]:25, delay=0.63, delays=0.01/0.01/0.11/0.51, dsn=5.7.1, status=bounced (host mx.workaround.org[85.214.93.191] said: 554 5.7.1 Service unavailable; Sender address [spammer@example.com] blocked using dsn.rfc-ignorant.org; Not supporting null originator (DSN) (in reply to RCPT TO command))
Feb 27 18:01:41 svrNEU postfix/cleanup[11906]: 17C4720DA284: message-id=<20100227170141.17C4720DA284@svrNEU.de.de>
Feb 27 18:01:41 svrNEU postfix/bounce[11914]: 6D3A920DA287: sender non-delivery notification: 17C4720DA284
Feb 27 18:01:41 svrNEU postfix/qmgr[11899]: 17C4720DA284: from=<>, size=3309, nrcpt=1 (queue active)
Feb 27 18:01:41 svrNEU postfix/qmgr[11899]: 6D3A920DA287: removed
Feb 27 18:01:41 svrNEU postfix/pipe[11912]: 17C4720DA284: to=<spammer@example.com>, relay=dovecot, delay=0.04, delays=0.03/0/0/0.01, dsn=2.0.0, status=sent (delivered via dovecot service)
Feb 27 18:01:41 svrNEU postfix/qmgr[11899]: 17C4720DA284: removed
Feb 27 18:01:42 svrNEU postfix/smtpd[11902]: disconnect from localhost[127.0.0.1]