• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

manual smtp session is not working anymore

Hi experts

I make my bash scripts send mail through a simple "mail.sh" script (see attached code snippet).

But for a few days, I cannot send anymore this way. I tried an smtp session manually, and apparently the problem is that the end of the message is not recognised.

Yet I enter a dot on a line by itself just as the smtp server says to do  ("Enter mail, end with "." on a line by itself").

And it used to work beautifully.

Any idea what I add to my script to make the smtp server recognize the end of DATA ?

thanks a lot


PS : I do not have control over the smtp server
#! /bin/sh 
nc mymailserver.com 25 << FIN
EHLO mymailserver.com
auth plain aaaa_MYBASE64PASSWORD___aaa
MAIL FROM: sender@mymailserver.com 
RCPT TO: $1 
DATA 
Subject: $2
$3
 
.
quit
FIN

Open in new window

0
Michaelhv
Asked:
Michaelhv
  • 2
  • 2
  • 2
1 Solution
 
chris_barryCommented:
I'm afraid I can't see what is wrong with your script, but have you considered using blat?
0
 
chris_barryCommented:
Sorry, I thought that blat was a Linux utility which had been ported to Windows. I see now that it is Windows only.

What I should have said was consider using sendmail.
0
 
alien_life_formCommented:
As for the script, I think you may be having a <LF><CR> problem (in that the receiving server insists on a final <CR>, that the BASH script is not sending. (qmail poses this kind of problems... of course qmail POV is that it is doing the right thing.)


You may want to either:
i) Rewrite in a different language (e.g. perl) usinf a mail library
ii) use a system command, either mail or sendmail would do the trick.

Cheers,
alf
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
MichaelhvAuthor Commented:
hello ; thanks for the comment, but I'd like to stick with the bash script. Is there a way I can make it send a <LF><CR> ?
0
 
alien_life_formCommented:
Not that I know of, not with nc.

But please note that using (for example) sendmail involves nothing more than replacing "nc mymailserver.com 25" with "sendmail -bm", and a properly configured local sendmail (or moral equivalent). You'd still be sticking with the shell script.

Cheers,
alf
0
 
MichaelhvAuthor Commented:
hello

I found the solution : thanks to your input, I understood it was a problem with crlf. So I did a text file with
crlf
.
crlf

, and in my script I added the line mycrlf=`cat mycrlffile.txt`

I used the utility http://ccrma-www.stanford.edu/~craig/utility/flip/ to make sure my crlfile.txt file used crlf line endings (dos-style).

thanks !
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now