Solved

manual smtp session is not working anymore

Posted on 2008-09-30
6
518 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
  • 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

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…
Pop culture is prime bait for hackers seeking to infect user’s computers and mobile devices with malicious malware. Hackers know exactly what the latest trends are online and know how to use them to their advantage.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

785 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