Messaging
cancel
Showing results for 
Search instead for 
Did you mean: 

Send mails via sendmail out from application

SOLVED
Go to solution

Send mails via sendmail out from application

Gentlemen,

we want to send out mails from an application.
Therefor the application create a tmp.-file
which contain all necessary information (e.g):

->>>> top of file
MAIL FROM: x.y@domain.com
RCPT TO: z.y@Ndomain.com
DATA
TO: x y
From: z y
Date: Fri, 08 Aug 2003 20:57:47 +0001
Subject: Testmail
Nachrichtentext
.
<<<<----end of file

We used the following command:
cat tmp-file | sendmail -bs -fit-operations@domain.com

What can I say, IT WORKS! BUT sendmail write out the following messages:

220 norskehp. ESMTP Sendmail 8.9.3 (PHNE_24419)/8.7.1; Tue, 25 Nov)
250 x.y@domain.com... Sender ok
250 y.z@domain.com... Recipient ok
354 Enter mail, end with "." on a line by itself
250 MAA05087 Message accepted for delivery
503 Need MAIL before RCPT
503 Need MAIL command
500 Command unrecognized: "TO: x y "
500 Command unrecognized: "From: y z "
500 Command unrecognized: "Date: Fri, 08 Aug 2003 20:57:47 +0001"
500 Command unrecognized: "Subject: Testmail"
500 Command unrecognized: "Nachrichtentext"
500 Command unrecognized: "."

Any suggestions from the smart guys??

Regards,
-Andraes
7 REPLIES
Graham Cameron_1
Honored Contributor

Re: Send mails via sendmail out from application

Could it be that you are confusing sendmail by packing things into your tmp file which it is actually responsible for adding ?

Change your tmp file so it only contains the text of the message (don't need the closing dot either), and then use mailx to send the message. eg.

/usr/bin/mailx -s "Subject" x.y@domain.com < tmp-file

-- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.
Elmar P. Kolkman
Honored Contributor

Re: Send mails via sendmail out from application

Are you sure it works ?!?
It seems it sends the lines after DATA to sendmail outside the data block, even though it should work the way you use it. So I would make sure if the text "Nachrichtentext" is indeed in the mail you receive...

Graham's solution is a lot nicer, and more generic. The only limit is that your from address is the address of the user sending the mail, not the address you want to specify.

Another thing you could try BTW:
cat tmpfile | telnet 0 25
Every problem has at least one solution. Only some solutions are harder to find.

Re: Send mails via sendmail out from application

Hi Graham & Elmar,

thanks for your ideas. But two weak points:

1. mailx uses the sender of the processuser
2. cat tmpfile | telnet 0 25 also produces the same error messages

Regards,
-Andreas
Elmar P. Kolkman
Honored Contributor
Solution

Re: Send mails via sendmail out from application

Sorry, but I didn't try it. But it can work. Strip the first 3 lines from tmpfile, and drop the last (dot) line.
Then call it the following way:
cat tmpfile | sendmail -fx.y@domain.com z.y@domain.com

I have tried, and this works for me, so it should work for you too... You can even add a -F'' to the sendmail arguments...
Every problem has at least one solution. Only some solutions are harder to find.
Graham Cameron_1
Honored Contributor

Re: Send mails via sendmail out from application

If you want to hide the true sender, then you can use the Masquerade as (DM) macro in sendmail.cf

- Graham
Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done.

Re: Send mails via sendmail out from application

Now the results of the german jury:

ELMARS HINT HITS!

Thanks to you all and have a nice day.

Regards,
-Andreas

Re: Send mails via sendmail out from application

Gentlemen,

we found the absolute solution:

cat neu.txt | /usr/sbin/sendmail -t

Then sendmail read also the SMTP tags.

Regards,
-Andreas