Solved

Problems with "Mail" program

Posted on 1997-09-08
13
154 Views
Last Modified: 2013-12-25
-->I'm using the following snippet of script to send mail from a form:

sub sendthemail {  # Send Article Posted To Administrator
  if ($sendmail == 1) {
    open (MAIL, "|$mailprog $host") || die "Can't open $mailprog!";
    print MAIL "From: $email\n";
    print MAIL "Subject: $title Message sent \n";
    print MAIL "Reply-To: $email\n\n";
    print MAIL " The following e-mail has been sent to all subscribers.\n";
    print MAIL "Dated  : $long_date\n";
    print MAIL "Subject: $subject\n";
    print MAIL "======================================================\n";
    print MAIL "$email_body\n";
    print MAIL "======================================================\n";
    close (MAIL);
  }

-->BUT when the message is received the From, Subject and Reply-to headers that I wanted have been included in the message as ordinary text:

Subject:
  Date: Mon, 8 Sep 1997 22:24:39 +0100
  From: Nobody <nobody@compsoc.man.ac.uk>
    To: MUUCU@bigfoot.com


From: MUUCU.WebMaster@bigfoot.com
Subject: MUUCU Mailing Archive Message sent
Reply-To: MUUCU.WebMaster@bigfoot.com

 The following e-mail has been sent to all subscribers.
Dated  : September 08, 1997 at 22:24:38
Subject: TEST RUN1002
======================================================
TEST RUN
======================================================

-->So What can I do to fix this?
0
Comment
Question by:MrG
  • 7
  • 3
  • 2
  • +1
13 Comments
 

Author Comment

by:MrG
ID: 1830147
Edited text of question
0
 
LVL 84

Expert Comment

by:ozo
ID: 1830148
That depends on your $mailprog
If it's /usr/lib/sendmail on a standard unix system, I'd have expected the above to work.
If it's some other program, you may need to check its documentation.
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1830149
I had the same problem - with sendmail on Unix, BTW.

Solution? Just add the following line after the open() stuff:

print MAIL "Mime-Version: 1.0\n"

Hope this works for you, as well.

Rgds, julio
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 84

Expert Comment

by:ozo
ID: 1830150
julio, what version of sendmail was this that required "Mime-Version: 1.0\n" ?
0
 

Author Comment

by:MrG
ID: 1830151
As I said at the top of the question, it was not SENDMAIL that I am using it was mail, but I've got SENDMAIL installed so It's working okay with OZO's suggestion!
0
 
LVL 84

Expert Comment

by:ozo
ID: 1830152
Sorry, so many things called mail or Mail that it wasn't clear whether
that was a name or a description of $mailprog
So, if that comment got it working for you, will you take
using /usr/lib/sendmail as the answer?
(I don't want to submit it as an answer just yet, to give julio
a chance to answer my question without having to pay points just to come
back to this discussion:-)
 

0
 
LVL 5

Expert Comment

by:julio011597
ID: 1830153
Hi ozo,

i cannot guess which version of sendmail i'm running;
just can tell that it's on a Digital AlphaServer running OSF1 V4.0 386.

Cheers, julio

P.S.

hey, Mr G., "using the following snippet of script to send mail from a form" is what i could not see at the top of your question?
0
 
LVL 84

Expert Comment

by:ozo
ID: 1830154
I'm not familiar with that system (but I thought they supported V8 sendmail)
Can you tell anything from Received: headers, or sendmail -d?

(Ok, Thanks for the use of your question thread MrG,
I'll let you take it back now:-)
0
 
LVL 5

Expert Comment

by:julio011597
ID: 1830155
 Mr Ozo ;)

in fact, i've made a mistake; it was not for headers that i had to add that line, it was for attachments to work.

I.e., i had setup a CGI to send back a gif to a client, via mail, but the attachment was garbage when read with Eudora or on a Mac.
I didn't investigate too much on which exact versions of Eudora or MacOS caused the problem.
Since that modification, anyway, everybody has been receiving good attachments.

-julio
0
 
LVL 84

Expert Comment

by:ozo
ID: 1830156
Ah, that makes much more sense now, thanks for the clarification.
0
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 1830157
I guess we still need an Answer:

The given snippet should work for $mailprog='/usr/lib/sendmail' on a standard unix system.
Another $mailprog on another system may want something different.
0
 
LVL 84

Expert Comment

by:ozo
ID: 1830158
If you are unsatisfied with the answer, did you have a furthur question?

0
 

Expert Comment

by:gcr
ID: 1830159
ozo -


In your script I see that you are not designating a "To;" ahead of your "From:", "Reply-To:", etc.

Try putting:

print MAIL "To: $CONFIG{'recipient'}\n";

Ahead of your line:

print MAIL "From: $email\n";


0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

810 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