Sponsored Content
Top Forums UNIX for Advanced & Expert Users mailx commannd - Mail and Attachment in same mail Post 302169916 by kpearson on Saturday 23rd of February 2008 02:31:59 AM
Old 02-23-2008
You have to include the following lines in the header of the email to have the file go as an attachment:

Code:
Content-Disposition: attachment; filename="filename.ext"
Mime-Version: 1.0
Content-Type: text/plain
... rest of email ...

And you will probably have to not use mailx and use sendmail with a command like:

Code:
/usr/sbin/sendmail -t -iep < emailfilename

But, for that to work, the file, emailfilename has to have a From: line, a Date: line and a Subject: line. There has to be a blank line after these header lines, the ones above, and the start of the data.

Here's a commandline script I wrote for AIX, but which should work just about anywhere you have access to sh (bash, ksh, sh):

Code:
#!/usr/bin/ksh

if [ $# -lt 4 ] ; then
 echo "USAGE: send.email UNIXDIR UNIXFILE FROM@atsindustrial.com TO@ADDR.com"
exit 1
fi

UNIXPATH="$1"
UNIXFILE="$2"
FROMADDR="$3"
TOADDR="$4"

if [ -f "$UNIXPATH/$UNIXFILE" ] ; then
 OBJECT="$UNIXPATH/$UNIXFILE"
 cat "$OBJECT" | /usr/sbin/sendmail -oi -t -f $FROMADDR $TOADDR
else
 echo "$UNIXPATH/$UNIXFILE not valid..."
 exit 2
fi

exit 0

HTH

Last edited by kpearson; 02-23-2008 at 03:37 AM.. Reason: addition of a script to call . . .
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mail or mailx attachment

I have used the forum to determine the format required to send attachments from hp-ux 11. the problem I have is that using mailx does not attach the file, but subsititing mailx for mail on the command line attaches the file but i'm not able to specify a subject? The attachment has been convert... (3 Replies)
Discussion started by: brettmartin99
3 Replies

2. Shell Programming and Scripting

Problem with Mailx command to send mail with attachment

Hi, I am using mailx command to send a mail with attachment. It's working fine, but with attachment I am getting one extra attachment like (ATT00131.txt). I have tried to use unix2dos command also. But still I am getting the extra attachment. I am using the following code: subject="temp... (5 Replies)
Discussion started by: viswanatharv
5 Replies

3. Shell Programming and Scripting

Mail attachment with unix mail

Hi Could someone help me with the details on how to send an attachment through mail in unix. I have an html file in my unix machine and I want this to be send to some mail id, plese help with the steps. Regards Ajay (2 Replies)
Discussion started by: ajaykumarboyana
2 Replies

4. UNIX for Advanced & Expert Users

how to send file as attachment using mail or mailx

I have a need to send a file from the unix command line to be sent as an attachment. Is this possible? That is when I open my outlook email I need to file to appear as an attachment. Also, is there a way to use the mail binary (not mailx) to modify the "reply address". mailx -r works but I need... (1 Reply)
Discussion started by: kieranfoley
1 Replies

5. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

6. Shell Programming and Scripting

send attachment and body in one mail using mailx

Hi, Our requirement is to send an attachment and content in a single mail. I am using the below command to send attachement. --------------------- (uuencode $exp_file $exp_file) |mailx -s "$email_subject" $EmailRecipients -------------------- I m not able to send any message in the... (4 Replies)
Discussion started by: ashwin3086
4 Replies

7. UNIX for Advanced & Expert Users

need to configure mail setting to send mail to outlook mail server

i have sun machines having solaris 9 & 10 OS . Now i need to send mail from the machines to my outlook account . I have the ip adress of OUTLOOK mail server. Now what are the setting i need to do in solaris machines so that i can use mailx or sendmail. actually i am trying to automate the high... (2 Replies)
Discussion started by: amitranjansahu
2 Replies

8. Shell Programming and Scripting

Not able to send the mail using mail and mailx command

Hi All, I am trying to send a mail from linux server but could'nt able to send the mail. I tried the below syntax's so far but no luck. mail -s “Hello world” abc@xyz.com < /usr/g/txt.log cat "txt.log" | mailx -s "Hello world" abc@xyz.com mailx -s “Hello world” abc@xyz.com <... (2 Replies)
Discussion started by: scriptscript
2 Replies

9. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

10. UNIX for Advanced & Expert Users

Client was not authenticated to send anonymous mail during MAIL FROM (in reply to MAIL FROM comm

I am having trouble getting mail to work on a red hat server. At first I was getting this message. Diagnostic-Code: X-Postfix; delivery temporarily suspended: connect to :25: Connection refused Then added the port to my firewall. Then I temporarily turned off selinux. I then copied this file... (1 Reply)
Discussion started by: cokedude
1 Replies
NMUDIFF(1)						      General Commands Manual							NMUDIFF(1)

NAME
nmudiff - email an NMU diff to the Debian BTS SYNOPSIS
nmudiff [options] DESCRIPTION
nmudiff should be run in the source tree of the package being NMUed, after the NMU is built. It assumes that the source packages (specifi- cally, the .dsc and any corresponding tar and diff files) for both the previous version of the package and the newly built NMU version are in the parent directory. It then uses debdiff to generate a diff between the previous version and the current NMU, and either runs mutt or an editor (using sensible-editor) so that the mail message (including the diff) can be examined and modified; once you exit the editor the diff will be mailed to the Debian BTS. The default behaviour is that if exactly one bug is closed by this NMU, then that bug will be mailed, otherwise a new bug will be submit- ted. This behaviour may be changed by command line options and configuration file options. OPTIONS
--new Instead of mailing the bug reports which are to be closed by this NMU, a new bug report is submitted directly to the BTS. --old Send the bug report to all of the bugs which are being closed by this NMU, rather than opening a new bug report. This option has no effect if no bugs are being closed by this NMU. --mutt Use mutt(1) for editing and sending the message to the BTS (default behaviour). This can be controlled using a configuration file option (see below). --no-mutt Use sensible-editor(1) to edit the message and then mail it directly using /usr/bin/sendmail. This can be controlled using a con- figuration file option (see below). --sendmail SENDMAILCMD Specify the sendmail command. The command will be split on white space and will be interpreted by the shell. Default is /usr/sbin/sendmail. The -t option will be automatically added if the command is /usr/sbin/sendmail or /usr/sbin/exim*. For other mailers, if they require a -t option, this must be included in the SENDMAILCMD, for example: --sendmail="/usr/sbin/mymailer -t". This can also be set using the devscripts configuration files; see below. --from EMAIL If using the sendmail (--no-mutt) option, then the email to the BTS will be sent using the name and address in the environment vari- ables DEBEMAIL and DEBFULLNAME. If these are not set, then the variables EMAIL and NAME will be used instead. These can be over- ridden using the --from option. The program will not work in this case if an email address cannot be determined. --delay DELAY Indicate in the generated mail that the NMU has been uploaded to the DELAYED queue, with a delay of DELAY days. The default value is XX which adds a placeholder to the e-mail. A value of 0 indicates that the upload has not been delayed. This can also be set using the devscripts configuration files; see below. --no-delay, --nodelay Equivalent to --delay 0. --no-conf, --noconf Do not read any configuration files. This can only be used as the first option given on the command-line. --help Display a help message and exit successfully. --version Display version and copyright information and exit successfully. CONFIGURATION VARIABLES
The two configuration files /etc/devscripts.conf and ~/.devscripts are sourced in that order to set configuration variables. Command line options can be used to override configuration file settings. Environment variable settings are ignored for this purpose. The currently recognised variables are: NMUDIFF_DELAY If this is set to a number, e-mails generated by nmudiff will by default mention an upload to the DELAYED queue, delayed for the specified number of days. The value 0 indicates that the DELAYED queue has not been used. NMUDIFF_MUTT Can be yes (default) or no, and specifies whether to use mutt to compose and send the message or not, as described above. NMUDIFF_NEWREPORT This option controls whether a new bug report is made, or whether the diff is sent to the bugs closed by this NMU. Can be maybe (default), which sends to the existing bug reports if exactly one bug is being closed; yes, which always creates a new report, or no, which always sends to the reports of the bugs being closed (unless no bugs are being closed, in which case a new report is always made). BTS_SENDMAIL_COMMAND If this is set, specifies a sendmail command to use instead of /usr/sbin/sendmail. Same as the --sendmail command line option. SEE ALSO
debdiff(1), sensible-editor(1) and devscripts.conf(5). AUTHOR
nmudiff was written and is copyright 2006 by Steinar H. Gunderson and modified by Julian Gilbey <jdg@debian.org>. The software may be freely redistributed under the terms and conditions of the GNU General Public License, version 2. DEBIAN
Debian Utilities NMUDIFF(1)
All times are GMT -4. The time now is 07:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy