mailx is not working

Hey,

I am running a opensuse 11.4 with mailx 12.2. I am trying to sent emails via command line using mailx. I have not configured any mail server in yast. My .mailrc in my homefolder looks like this:

set smtp-use-starttls

account gmx {
set smtp:465=mail.gmx.net
set smtp-auth=login
set smtp-auth-user=my.name@gmx.de
set smtp-auth-password=mypassword
set from=“My name <my.name@gmx.de>”
}

Unfortunately when I use the command

mailx -s"Test" -A gmx my.name@gmx.de [Return]
Hallo
[ctrl+d]

I am getting only the message

Unexpected EOF on SMTP connection
“/home/myname/dead.letter” 11/338
. . . message not sent.

Does anyone know where the bug is.

Thanks a lot

Rexi

“mailx” is only part of the story.

“mailx” is an MUA (Mail User Agent). It is used to read mail that you receive, and to compose mail that you will send.

The other part of the story is the MTA (Mail Transfer Agent). The MTA is responsible for transferring the message to the destination system.

In a typical opensuse install, the MTA used is postfix. However, postfix requires some configuration. Have you done that yet?

The simplest setup is when your ISP has a mail server to which your mail can be sent, and the ISP handles it from there. As I recall, setting up postfix is fairly simple once you know the identity of the ISP server. (Personally, I am not using postfix and don’t have it installed, so I can’t give details on setting that up.

If you get into Yast, there should be a section for network services. And you should be able to configure postfix there.

In case I haven’t been clear, your problem is almost certainly with the MTA rather than with mailx.

Actually he’s connecting to mail.gmx.de at port 465 directly which is allowed. However port 465 assumes TLS encrypted sessions and according to the mailx man page you need the syntax smtps://mail.gmx.de:465.

          There  are  two possible methods to get SSL/TLS encrypted
          SMTP sessions: First, the STARTTLS command can be used to
          encrypt a session after it has been initiated, but before
          any   user-related    data    has    been    sent;    see
          smtp-use-starttls  above.   Second,  some  servers accept
          sessions that are encrypted from their beginning on. This
          mode  is configured by assigning smtps://server:port] to
          the smtp variable.

rexi76 wrote:

>
> Hey,
>
> I am running a opensuse 11.4 with mailx 12.2. I am trying to sent
> emails via command line using mailx. I have not configured any mail
> server in yast. My .mailrc in my homefolder looks like this:
>
> set smtp-use-starttls
>
> account gmx {
> set smtp:465=mail.gmx.net
> set smtp-auth=login
> set smtp-auth-user=my.name@gmx.de
> set smtp-auth-password=mypassword
> set from=“My name <my.name@gmx.de>”
> }
>
> Unfortunately when I use the command
>
> mailx -s"Test" -A gmx my.name@gmx.de [Return]
> Hallo
> [ctrl+d]
>
> I am getting only the message
>
> Unexpected EOF on SMTP connection
> “/home/myname/dead.letter” 11/338
> . . . message not sent.
>
> Does anyone know where the bug is.

I use pretty much the same code to send notices from a remote machine. The
only difference I see in your code is here:

CODE

smtp:465=mail.gmx.net

/CODE

where mine is

/CODE

smtp=smtp://mail.whonea.net:587

/CODE

Note the protocol spec on the smtp server address. I just checked and my
script also fails w/o the smtp:// spec on the server url.

I had so much trouble getting this set up that I still have the paremeters
inline rather than an an account clause - it took me a while to get it right
but then I’m a real novice at bash scripting.


Will Honea

Will Honea wrote:

> rexi76 wrote:
>
>>
>> Hey,
>>
>> I am running a opensuse 11.4 with mailx 12.2. I am trying to sent
>> emails via command line using mailx. I have not configured any mail
>> server in yast. My .mailrc in my homefolder looks like this:
>>
>> set smtp-use-starttls
>>
>> account gmx {
>> set smtp:465=mail.gmx.net
>> set smtp-auth=login
>> set smtp-auth-user=my.name@gmx.de
>> set smtp-auth-password=mypassword
>> set from=“My name <my.name@gmx.de>”
>> }
>>
>> Unfortunately when I use the command
>>
>> mailx -s"Test" -A gmx my.name@gmx.de [Return]
>> Hallo
>> [ctrl+d]
>>
>> I am getting only the message
>>
>> Unexpected EOF on SMTP connection
>> “/home/myname/dead.letter” 11/338
>> . . . message not sent.
>>
>> Does anyone know where the bug is.
>
> I use pretty much the same code to send notices from a remote machine.
> The only difference I see in your code is here:
>
> CODE
> -----------
> smtp:465=mail.gmx.net
> -----------
> /CODE
>
> where mine is
>
> /CODE
> -----------
> smtp=smtp://mail.whonea.net:587
> -----------
> /CODE
>
> Note the protocol spec on the smtp server address. I just checked and my
> script also fails w/o the smtp:// spec on the server url.
>
> I had so much trouble getting this set up that I still have the paremeters
> inline rather than an an account clause - it took me a while to get it
> right but then I’m a real novice at bash scripting.

Just noticed that I skipped over a parameter. I also use

CODE

-S ssl-verify=ignore

/CODE

that would go into your account clause as

CODE

set ssl-verify=ignore

/CODE


Will Honea

Will Honea wrote:

> Just noticed that I skipped over a parameter. I also use
>
> CODE
> -------
> -S ssl-verify=ignore
> -------
> /CODE
>
> that would go into your account clause as
>
> CODE
> --------
> set ssl-verify=ignore
> --------
> /CODE
>

Trying to clean up my script, I see that you set smtp-use-starttls outside
of the account definition and not in the mailx arguments - you sure that
works? Try moving it inside the account gmx definition or onto the mailx
command line.


Will Honea

Ports 465 and 587 have different behaviour. 465 assumes it is TLS always so the protocol is smtps. 587 requires a STARTTLS command to switch so the protocol is smtp. However the server may reject the connection if no STARTTLS is issued before authenticating and uploading mail, for security reasons.

ken yap wrote:

>
> Ports 465 and 587 have different behaviour. 465 assumes it is TLS always
> so the protocol is smtps. 587 requires a STARTTLS command to switch so
> the protocol is smtp. However the server may reject the connection if no
> STARTTLS is issued before authenticating and uploading mail, for
> security reasons.

Told you I was a novice at this, didn’t I? Took me a week to get the script
working to get my external IP address, check against the last one I had,
then email a message containing the new IP if it had changed. Along the way
I dug up a lot of documentation but never did find a coherent description of
the email systems. Do you have some you could recommend?


Will Honea

I sort of worked it out by trial and error also. Probably the best references are the RFCs defining the use of these ports: 465 = smtps (actually deprecated), 587 = submission. Note that some servers also support STARTTLS on port 25. I know that gmail does, which is useful when you find that 587 is not usable for some reason. STARTTLS is sort of an add-on to an existing port, it is just another command that can be supported with the extended command set of ESMTP.

Thanks for the hints. By crossclassifying all proposal I found out the following

It works:

account gmx {
set smtp-use-starttls
set smtp=smtp://mail.gmx.net:587
set smtp-auth=login
set smtp-auth-user=my.name@gmx.de
set smtp-auth-password=mypassword
set from=“My name <my.name@gmx.de>”
}

It works not:

account gmx {
set smtp=smtps://mail.gmx.net:465
set smtp-auth=login
set smtp-auth-user=my.name@gmx.de
set smtp-auth-password=mypassword
set from=“My name <my.name@gmx.de>”
}

The error message then is: smtp-server: 554 5.5.1 This session already uses TLS {mp036}

Thanks

rexi

Yeah use 587. 465 is somewhat deprecated anyway.

According to mailx online documentation, and as mentioned by somebody earlier, mailx is only MUA, but is using a separate Mail Transfer Agent (MTA), which is run as a child process. Apparently, MUA can exit without MTA finishing send, especially if there is an attachment, hence the error

SMTP: Connection reset by peer
Unexpected EOF on SMTP connection
. . . message not sent.

I have added -S sendwait option, which seemed to solve this problem.