Solved

Problems with "Mail" program

Posted on 1997-09-08
13
158 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
[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
  • 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
How our DevOps Teams Maximize Uptime

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

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

733 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