Solved

Problems with "Mail" program

Posted on 1997-09-08
13
157 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
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 strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

839 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