- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Forward mail file with mail/mailx/sendmail
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-30-2010 07:31 AM
тАО11-30-2010 07:31 AM
Forward mail file with mail/mailx/sendmail
So just doing:
cat mail.file | mailx admin@server
doesn't work because the headers are included in the body and the subject will be blank (or a different subject if I use the -s option).
Basically what I'm looking for would be a way to script the way elm does a "forward mail" command, except elm only does that in interactive mode, unfortunately.
- Tags:
- sendmail
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-30-2010 08:22 AM
тАО11-30-2010 08:22 AM
Re: Forward mail file with mail/mailx/sendmail
Now my favorite way to do this, since I can send any kind of file (msword, raw text, tiff image, etc.) and script it is:
I have two files.
1. message.file will print in the body of the email
2. file-to-mail will show up as an attachment!
Create a /path/dummy file that states
[include /path/message.file text/plain base64]
[include /path/file-to-mail text/plain base64]
I don't know who told you that you can't script using elm ???....it's always worked for me.
In my script to mail is the following line:
elm -s " Sending the file " someguy@somecompany.com < /path/dummy
Just one method...read the threads and you will find plenty more!
Rgrds,
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-30-2010 08:51 AM
тАО11-30-2010 08:51 AM
Re: Forward mail file with mail/mailx/sendmail
I'm not looking for a way to send the file as an attachment. I want to treat the file as an SMTP mail message that I then forward to an email address. I don't have control over the mail file itself or its contents... it gets generated (as an email message) on another system and then transferred as a raw file to my system. The eventual recipient of the message doesn't need to see all of the mail headers and such in the message that they read. They just want the body of the message and the exact same subject as is.
As far as using elm, yes you can use it in scripts, but the "foward mail" feature is only available in interactive mode, so I can't take advantage of that via command line. If I could, that would solve my problem.
To make it more clear, look at this example of scripting a reply to a mail message saved as a file:
mailx -f mail.file <
This is an automated response, please do not reply.
EOF
Using the above, I'm able to reply to a message saved in mail.file and the return messaged has the same subject and just the body of the message that's being replied to. If there were a similar command to do a foward, then I'd be set, but there's no such thing with mailx, unfortunately.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-30-2010 12:33 PM
тАО11-30-2010 12:33 PM
Re: Forward mail file with mail/mailx/sendmail
But before doing that, we should examine the "raw mail file" a bit further.
- Is it certain that one file contains only one email message, and not several?
- Is the file in Berkeley mailbox format, or an actual raw mail file?
http://en.wikipedia.org/wiki/Berkeley_mailbox_format
If your file is in Berkeley mailbox format and might contain multiple messages, the "formail" command that comes with the free "procmail" software package would be useful:
http://hpux.connect.org.uk/hppd/hpux/Networking/Mail/procmail-3.22/
If what you have really is a raw mail file, I think simply piping it to sendmail should do the trick:
sendmail admin@server < mail.file
It should preserve just about all the headers, including the subject.
If it is a Berkeley mailbox with just a single message, you'll need to remove the "From " pseudo-header that indicates the beginning of the message, and probably also un-escape any escaped ">From " lines in the message body. (Note: "From
Off the top of my head, I'd try something like this:
grep -v "^From " mail.file \
| sed -e 's/^>From /From /g' \
| sendmail admin@server
If it's possible the file contains multiple messages, the previous solution could be made into a script or a shell function:
---- script send-single.sh ----
#!/bin/sh
# NOTE: mail message should be piped in
grep -v "^From " \
| sed -e 's/^>From /From /g' \
| sendmail "$@"
---- end script ----
Then "formail -s" could be used to split the file into multiple messages and send each of them:
cat mail.file | formail -s send-single.sh admin@server
Disclaimer: not tested, just trying to give you some ideas.
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 05:02 AM
тАО12-01-2010 05:02 AM
Re: Forward mail file with mail/mailx/sendmail
The messages come to my server as individual files (one file per message) and they are indeed stored in the Berkeley format that you referred to (each message beginning with "From "), however redirecting each file into sendmail did work, somewhat. The messages arrive in the recipient's mailbox with the original subject and just the original body, so that at least was progress.
However, it wasn't exactly the same as forwarding a message because there was no indication of where the original message came from and who sent it, at least not without examining the (now hidden) headers. It acted more like relaying the message than forwarding it, but it was a very good suggestion and I give you credit for that.
I eventually was able to solve the problem using the Linux version of mailx called "nail". Surprisingly enough it does include the "forward" command that's missing from the HP-UX version. I wasn't happy about switching to a Linux server to accomplish this, but it's the only thing I found that worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-01-2010 05:09 AM
тАО12-01-2010 05:09 AM
Re: Forward mail file with mail/mailx/sendmail
echo "forward admin@server" | nail -f mail.file