For Programmers: Free Programming Magazines  


Home > Archive > Unix Shell Programming > December 2004 > mail command and HTML email









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mail command and HTML email
rsine

2004-12-17, 3:58 pm

I have been using the mail command to send plain text emails but now
have the need to create emails with a little more pizzazz. So I
thought I could use HTML. Not being overly fluent in Unix and having
little experience with HTML I am sing any guidance on how to go
about doing this.

-Thanks

dfrench@mtxia.com

2004-12-17, 3:58 pm


rsine wrote:
> I have been using the mail command to send plain text emails but now
> have the need to create emails with a little more pizzazz. So I
> thought I could use HTML. Not being overly fluent in Unix and having
> little experience with HTML I am sing any guidance on how to go
> about doing this.
>


To send multi-part HTML encoded emails from a script or command line in
Unix will require you to be fluent in Unix,scripting, and HTML. To
begin, you will want to see the following SMTP document:

http://www.mtxia.com/fancyIndex/Tools/smtp101.html


The following is an example Korn Shell script to
send multi-part mime messages. You can probably
modify this to suit your needs.

#!/usr/bin/ksh
########################################
########################

REPLYTO="dfrench@mtxia.com"
MAILADDR="somebody@somewhere.com"
SUBJECT="this is a test message"

exec 3>&-
exec 3>/dev/tcp/smtp.yourDomain.com/25

print -u3 "HELO ${REPLYTO#*@}"
print -u3 "MAIL FROM: ${REPLYTO}"
print -u3 "RCPT TO: ${MAILADDR}"

print -u3 "DATA
Subject: ${SUBJECT}
To: ${MAILADDR}
From: ${REPLYTO}
Reply-to: ${REPLYTO}
Mime-Version: 1.0
Content-Type: Multipart/Mixed; boundary=foo

--foo
Content-Type: text/plain;charset=\"ISO-8859-1\"

"

print "Sending Part 1 of a 3 part message"
cat part1.txt >&3

print -u3 '\n\n--foo
Content-Type: text/plain;charset="ISO-8859-1"
Content-Disposition: attachment;filename="DanaFrench.txt"

'

print "Sending DanaFrench.txt"
cat DanaFrench.txt >&3

print -u3 '\n\n--foo
Content-Type: application/x-msword;name="DanaFrench.doc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;filename="DanaFrench.doc"

'

print "Sending DanaFrench.doc"
perl -MMIME::Base64 -0777 -ne 'print encode_base64($_)' <
DanaFrench.doc >&3
print -u3 "\n\n."

print -u3 "QUIT"

exec 3>&-



--
Dana French

Alan Connor

2004-12-18, 8:56 pm

On 17 Dec 2004 09:19:22 -0800, dfrench@mtxia.com
<dfrench@mtxia.com> wrote:

> rsine wrote:
>
>
>
> To send multi-part HTML encoded emails from a script or command
> line in Unix


<snip>

HTML mail stinks, but one should understand it, and I've saved
your excellent post here, Dana. Thanks.


AC


rsine

2004-12-21, 3:59 pm

Dana,

Thanks for your post.

I found that I can create a file and then use sendmail in the form of:

sendmail -t < myemail.html

Inside the myemail.html file I have the following:

From: me@myaddress.com
To: you@youraddress.com
Subject: test
Content-Type: text/html
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename = "myemail.html"


<body>
<font size = 5>Hello World!</font>
</body>

The only issue I have with this is that it takes 1 minute to send the
email. This is irregardless of the length. Is there a way to shorten
this? I am thinking I might have to install another mail program to
get the speed I am looking for. Any suggestions? I am using AIX ver.
4.3.

Thanks again for your reply.

dfrench@mtxia.com

2004-12-21, 3:59 pm


rsine wrote:
> Dana,
>
> Thanks for your post.
>
> I found that I can create a file and then use sendmail in the form

of:
>
> sendmail -t < myemail.html
>
> Inside the myemail.html file I have the following:
>
> From: me@myaddress.com
> To: you@youraddress.com
> Subject: test
> Content-Type: text/html
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline; filename = "myemail.html"
>
>
> <body>
> <font size = 5>Hello World!</font>
> </body>
>
> The only issue I have with this is that it takes 1 minute to send the
> email. This is irregardless of the length. Is there a way to

shorten
> this? I am thinking I might have to install another mail program to
> get the speed I am looking for. Any suggestions? I am using AIX

ver.
> 4.3.
>


The timing problem is likely a configuration issue with sendmail or
your DNS. If it is the DNS, another mail program will not solve your
problem. sendmail is the backbone of Internet email and is your
friend. If you are starting up a new spamming business (as it sounds
like), it would be in your best interest to know and understand how
sendmail works.


--
Dana French - Mt Xia dfrench@mtxia.com
Mt Xia Technical Consulting Group http://www.mtxia.com
Ridmail - 100% Spam Free Email http://www.ridmail.com
MicroEMACS Binaries http://uemacs.tripod.com
Korn Shell Web http://dfrench.tripod.com

rsine

2004-12-21, 3:59 pm

Dana,

Is there something in particular I should be looking for in the
sendmail configuration? Again, I am not very fluent with Unix since the
company I work for mainly uses programs that do all the interaction
with Unix without anyone here needing to really know its inner
workings.

dfrench@mtxia.com

2004-12-21, 3:59 pm


rsine wrote:
> Dana,
>
> Is there something in particular I should be looking for in the
> sendmail configuration? Again, I am not very fluent with Unix since

the
> company I work for mainly uses programs that do all the interaction
> with Unix without anyone here needing to really know its inner
> workings.



You would have to describe a lot more detail about the problem,
symptoms, and attempted resolutions. Fixing sendmail configuration
problems will require you to be knowledgeable about sendmail. You may
be able to determine if you have any DNS issues by simply doing an
"nslookup" on the domain to which you are sending email, and timing how
long it takes to return.

--
Dana French

Luiz Henrique de Figueiredo

2004-12-21, 8:57 pm

In article <1103299275.356861.94740@z14g2000cwz.googlegroups.com>,
rsine <rsine@stationeryhouse.com> wrote:
>I have been using the mail command to send plain text emails but now
>have the need to create emails with a little more pizzazz. So I
>thought I could use HTML. Not being overly fluent in Unix and having
>little experience with HTML I am sing any guidance on how to go
>about doing this.


Try matt at ftp://ftp.tecgraf.puc-rio.br/pub/lhf/matt.tar.gz .
rsine

2004-12-23, 4:07 pm

Dana,

Is there something in particular I should be looking for in the
sendmail configuration? Again, I am not very fluent with Unix since the
company I work for mainly uses programs that do all the interaction
with Unix without anyone here needing to really know its inner
workings.

dfrench@mtxia.com

2004-12-28, 3:59 pm


rsine wrote:
> Dana,
>
> Is there something in particular I should be looking for in the
> sendmail configuration? Again, I am not very fluent with Unix since

the
> company I work for mainly uses programs that do all the interaction
> with Unix without anyone here needing to really know its inner
> workings.



You would have to describe a lot more detail about the problem,
symptoms, and attempted resolutions. Fixing sendmail configuration
problems will require you to be knowledgeable about sendmail. You may
be able to determine if you have any DNS issues by simply doing an
"nslookup" on the domain to which you are sending email, and timing how
long it takes to return.

--
Dana French

Luiz Henrique de Figueiredo

2004-12-28, 3:59 pm

In article <1103299275.356861.94740@z14g2000cwz.googlegroups.com>,
rsine <rsine@stationeryhouse.com> wrote:
>I have been using the mail command to send plain text emails but now
>have the need to create emails with a little more pizzazz. So I
>thought I could use HTML. Not being overly fluent in Unix and having
>little experience with HTML I am sing any guidance on how to go
>about doing this.


Try matt at ftp://ftp.tecgraf.puc-rio.br/pub/lhf/matt.tar.gz .
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com