Solved

Problems with "Mail" program

Posted on 1997-09-08
13
149 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
 
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

757 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now