Solved

manual smtp session is not working anymore

Posted on 2008-09-30
6
523 Views
Last Modified: 2013-12-26
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
Comment
Question by:Michaelhv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 1

Expert Comment

by:chris_barry
ID: 22603596
I'm afraid I can't see what is wrong with your script, but have you considered using blat?
0
 
LVL 1

Expert Comment

by:chris_barry
ID: 22603648
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
 
LVL 3

Accepted Solution

by:
alien_life_form earned 500 total points
ID: 22603902
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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

Author Comment

by:Michaelhv
ID: 22604125
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
 
LVL 3

Expert Comment

by:alien_life_form
ID: 22606326
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
 

Author Comment

by:Michaelhv
ID: 22606372
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Still having to process all these year-end "csv" files received from all these sources (including Government entities), sometimes we have the need to examine the contents due to data error, etc... As a "Unix" shop, our only readily …
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question