Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

manual smtp session is not working anymore

Posted on 2008-09-30
6
Medium Priority
?
534 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 1500 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
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!

 

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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

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…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.
Suggested Courses

597 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