I have seen some differing subjects (within the group) on this matter,
but nothing that seems to provide me with exactly what I am looking
for, or maybe I am not understanding the issue correctly in the 1st
place.
I have procedures in place to produce any PDF document required from
within D3. I currenty use "txt2PDF" from Sanface. This all works very
well on Linux. Generasting standard reports etc is no problem.
I now need to take this a step further and start to SEND these out via
email, from the Linux Server (primarily RedHat 9.0 and RedHat
Enterprise 3.0). I am quite happy with the actual syntax and
operational side of "sendmail" and "postfix". Sending "text" documents
is a breeze.
However, sending PDF files, or any type of file in essence, requires
they be sent as "attachments". This is where I am stuck !!!
Can anyone guide me as to what I need to do in terms of the EMAIL / PDF
file genration before using "sendmail" etc.
Regards
John
You need a Base64 encoder for Linux, i do not know if Red Hat 9 or
Enterprise has it.
I use one opensource software. Look in Google for a file named:
MIME-Base64-3.05.tar
Install it and change the basic instruction:
"EXECUTE "!/base/ibase64 ":PDFPATH CAPTURING OUTPUT"
to your directory.
Hope this help
joseba real de asua
frel...@sarenet.es
BASIC PROGRAM
*--------------------------------------------------------------------------------------------
PDFPATH = "/tmp/kalis.pdf"
NAME = "kalis.pdf"
PDF="kalis"
PDFNAME = NAME
*---------------------------------------------------
* codificar el documento PDF como BASE 64
*---------------------------------------------------
EXECUTE "!/base/ibase64 ":PDFPATH CAPTURING OUTPUT
PDFOUTPUT = OUTPUT
*-----------------------------------------------------------------------------------------------------
*
* Crear la cabecera del MAIL
*
*-----------------------------------------------------------------------------------------------------
Mensaje=''
Mensaje1=''
Mensaje1=Mensaje1: "Date: ":OCONV(DATE(),"D4"):"
":OCONV(TIME(),'MT'):CHAR(13):CHAR(10)
FROM = "ori...@dominio.com"
ORG = "Nombre"
SUBJECT = "PDF como anexo"
TOMAIL="a...@direccion.com"
CCMAIL="cop...@direccion.com"
Mensaje1=Mensaje1: "From:":FROM:CHAR(13):CHAR(10)
Mensaje1=Mensaje1: "Organizacion:":ORG:CHAR(13):CHAR(10)
Mensaje1=Mensaje1: "MIME-Version: 1.0":CHAR(13):CHAR(10)
Mensaje1=Mensaje1:"To:":TOMAIL:CHAR(13):CHAR(10)
Mensaje1=Mensaje1:"Cc: ":CCMAIL:CHAR(13):CHAR(10)
Mensaje1=Mensaje1: "Subject:":SUBJECT:CHAR(13):CHAR(10)
*---------------------------------------------------------------------------------------------------
*
* Marcar la parte MIME
*
*---------------------------------------------------------------------------------------------------
BOUNDARY="---------All-Spec-Boundary"
*---------------------------------------------------------------------------------------------------
*crear el e-mail como multipart/mixed para incluir el anexado
*---------------------------------------------------------------------------------------------------
Mensaje1=Mensaje1: "Content-type: multipart/mixed; "
Mensaje1=Mensaje1: 'boundary="':BOUNDARY:'";':CHAR(13):CHAR(10)
BOUNDARY="--":BOUNDARY
Mensaje=Mensaje1:CHAR(13):CHAR(10)
*---------------------------------------------------------------------------------------------------
* Marca Uno
*---------------------------------------------------------------------------------------------------
Mensaje=Mensaje:BOUNDARY:CHAR(13):CHAR(10)
Mensaje=Mensaje: "Content-Type: text/plain;
charset=us-ascii":CHAR(13):CHAR(10)
Mensaje=Mensaje: "Content-Transfer-Encoding: 7bit":CHAR(13):CHAR(10)
Mensaje=Mensaje:CHAR(13):CHAR(10)
TEXTMensaje="Prueba PDF"
Mensaje=Mensaje:TEXTMensaje:CHAR(13):CHAR(10)
Mensaje=Mensaje:CHAR(13):CHAR(10)
Mensaje=Mensaje:BOUNDARY:CHAR(13):CHAR(10)
*----------------------------------------------------------------------------------------------------
* Fin de la marca
*----------------------------------------------------------------------------------------------------
*----------------------------------------------------------------------------------------------------
*
* Especificar el tipo MIME como application/pdf ya que el anexado es un
documento PDF codificado en base64
*
*----------------------------------------------------------------------------------------------------
Mensaje=Mensaje:'Content-Type: application/pdf;
*----------------------------------------------------------------------------------------------------
*
* Nombrar la marca
*
*----------------------------------------------------------------------------------------------------
Mensaje=Mensaje:'name="':PDFNAME:'"':char(13):char(10)
*----------------------------------------------------------------------------------------------------
*----------------------------------------------------------------------------------------------------
* Decirle al cliente de e-mail que esta recibiendo datos codificados en
base64
*----------------------------------------------------------------------------------------------------
Mensaje=Mensaje:'Content-Transfer-Encoding: base64':CHAR(13):CHAR(10)
*----------------------------------------------------------------------------------------------------
* Decirle al cliente de e-mail que presente los datos como anexado
*----------------------------------------------------------------------------------------------------
Mensaje=Mensaje:'Content-Disposition: attachment; '
*----------------------------------------------------------------------------------------------------
* Nombrar el anexado
*----------------------------------------------------------------------------------------------------
Mensaje=Mensaje:'filename="':PDFNAME:'"':char(13):char(10)
Mensaje=Mensaje:CHAR(13):CHAR(10)
*----------------------------------------------------------------------------------------------------
* Añadir el PDF codificado en base64
*----------------------------------------------------------------------------------------------------
Mensaje=Mensaje:PDFOUTPUT:CHAR(13):CHAR(10)
Mensaje=Mensaje:CHAR(13):CHAR(10)
*-----------------------------------------------------------------------------------------------------
* Cerrar la parte MIME con 2 guiones al final a la derecha
*-----------------------------------------------------------------------------------------------------
Mensaje=Mensaje:BOUNDARY:"--":CHAR(13):CHAR(10)
*-----------------------------------------------------------------------------------------------------
* Mensaje MIME terminado
*-----------------------------------------------------------------------------------------------------
*-----------------------------------------------------------------------------------------------------
* Escribir el MIME en un directorio de Linux
*-----------------------------------------------------------------------------------------------------
open "unix:/tmp" to PDFTEMP
WRITE Mensaje ON PDFTEMP, PDF:".mail_pdf"
PATHTOMensaje = "/tmp/":PDF:'.mail_pdf'
*-----------------------------------------------------------------------------------------------------
* Enviarlo con SENDMAIL
*-----------------------------------------------------------------------------------------------------
EXECUTE '!/usr/sbin/sendmail -t -Rfull -fdire...@dominio.com <
':PATHTOMensaje CAPTURING OUTPUT RETURNING OUTPUT2
*-----------------------------------------------------------------------------------------------------
* Borrar el MIME
*-----------------------------------------------------------------------------------------------------
EXECUTE '!rm -f /tmp/':-pDF:"*"
*---------------------------------------------------------------------------------------------------------------
From the sendmail FAQ:
Q: How do I create attachments with sendmail?
A: You don't. Sendmail is a mail transfer agent (MTA). Creating e-mail
messages, including adding attachments or signatures, is the function
of a mail user agent (MUA). Some popular MUAs include mutt, elm, exmh,
Netscape, Eudora and Pine. Some specialized packages (metamail, some
Perl modules, etc.) can also be used to create messages with
attachments.
Solution 2:
http://www.google.com/search?hl=en&q=sendmail+attachments
That link brings you to the info above as well as:
http://home.clara.net/dwotton/unix/mail_files.htm
See BASH script from that page.
Beyond that, happy hunting. You'll see the solution is to convert the
attachments into Base64 and embed them in the mail as text.
Solution 3:
Have a look a the code sample for NebulaMail at this URL (some
assembly of the anti-spam URL required):
http://
removethisNebula-RnD
.com/products/mail.htm
The reason why I wrote NebulaMail is to save you guys from going
through all of the pain that's evident every time this request comes
up here in CDP. There's no need to mess with MIME types, MAPI,
sendmail, blat, SMTP, or any related protocols or programs. Sending
attachments with NebulaMail is as easy as setting a variable with the
path/filenames.
Extra notes:
- That web page above is old but mostly accurate, please contact me
for current info. For example, calling NEBULA.GET.MIME.TYPE is now
optional. I need time to update the page.
- The downloadable PDF User Guide is older as well but a good rough
guide. Please request a current doc if interested.
- NebulaMail is available for only $249US per server and is currently
only available for D3. The exact same code runs over Win32 and *nix.
Ports for other platforms have been done but not updated for lack of
demand - but I'm open for discussion.
- NebulaMail comes with a Lot of free functional sample code,
extensive docs for usage and troubleshooting, free installation
assistance, and free support. I can afford free support because the
code is stable and a change to the code hasn't been necessary in a
Long time. Some update/enhancements are in testing however, and
updates are free to our clients.
Solution 4:
Check with Ross at Stamina.
Tony
TG@
removethisNebula-RnD
.com
Visage.Emailer would certainly fit the bill, and when combined with
Visage.Reporter would even provide a powerful forms designer that can
generate PDF's, or just send to ANY printer, or use Visage.Faxer to fax
out.
(Emailer & Faxer can handle in & outbound traffic, allowing you to
direct incoming faxes to people via email, or have a Basic program
intelligently respond to an incoming email, or fax a text or HTML file
generate from Basic etc etc etc)
However, like our MailLynx product (free trial available for download
with documentation from www.stamina.com.au ), these would require the
presence of at least a Windows 2000 Pro machine (or more realistically
an XP machine these days) -hopefully not a biggie, but ....
Ross Ferris
Stamina Software
Visage - a complete solution to the application puzzle !
Scott Ballinger
Pareto Corporation
Edmonds WA USA
206 713 6006
Base64 encode the PDF document and then use MIME envelopes. There are
plenty of free base64 command line tools available. If you get one
make sure it will return the encoded data back to standard out for
'CAPTURING'.
Mime is very easy to use once you understand how boundaries and
content directives work. Note the dashes that are added before and
after the boundary name. These define the sections of the envelope and
also where the envelope stops. The boundary is defined in the header
with the header content-type. The header content-type will always be
multipart/mixed if you are sending more than one kind of data in a
single e-mail.
EMAIL is the e-mail address who is sending the e-mail. Anything in < >
means to fill in corresponding data. I use concatenation to assign all
the e-mail strings into one variable and then write it to a local disk
file via Q-pointer. Then, I call sendmail
EMAIL="mye...@myhost.com"
ORG="MY COMPANY"
SUBJECT="TESTING ATTACHMENTS"
TOMAIL="someon...@host.com"
EXECUTE '!base64 /tmp/email.pdf' CAPTURING PDFDATA
MSG=''
MSG=MSG:"Date: ":OCONV(DATE(),'D4'):CHAR(13):CHAR(10)
MSG=MSG:"From: ":EMAIL:CHAR(13):CHAR(10)
MSG=MSG:"Organization: ":ORG:CHAR(13):CHAR(10)
MSG=MSG:"To: ":TOMAIL:CHAR(13):CHAR(10)
MSG=MSG:"Subject: ":SUBJECT:CHAR(13):CHAR(10)
MSG=MSG:"MIME-Version: 1.0":CHAR(13):CHAR(10)
MSG=MSG:"Content-type: multipart/mixed;"
MSG=MSG:'boundary="unique-boundary";':CHAR(13):CHAR(10)
MSG=MSG:CHAR(13):CHAR(10)
MSG=MSG:"--unique-boundary":CHAR(13):CHAR(10)
MSG=MSG:"Content-type: text/plain; charset=us-ascii":CHAR(13):CHAR(10)
MSG=MSG:"Content-transfer-encoding: 7bit":CHAR(13):CHAR(10)
MSG=MSG:"Content-disposition: inline":CHAR(13):CHAR(10)
MSG=MSG:CHAR(13):CHAR(10)
MSG=MSG:"this is the text section of the mime envelope and it will be
displayed as a normal e-mail message.":CHAR(13):CHAR(10)
MSG=MSG:CHAR(13):CHAR(10)
MSG=MSG:"--unique-boundary":CHAR(13):CHAR(10)
MSG=MSG:"Content-type: application/pdf;"
MSG=MSG:"name=<name of attachment>":CHAR(13):CHAR(10)
MSG=MSG:"Content-transfer-encoding: base64":CHAR(13):CHAR(10)
MSG=MSG:"Content-disposition: attachment;"
MSG=MSG:"filename=<filename of attachment file>":CHAR(13):CHAR(10)
MSG=MSG:CHAR(13):CHAR(10)
MSG=MSG:PDFDATA:CHAR(13):CHAR(10)
MSG=MSG:CHAR(13):CHAR(10)
MSG=MSG:"--unique-boundary--":CHAR(13):CHAR(10)
WRITE MSG ON TMP.F, FILENAME:".email"
PATHTOMSG = "/tmp/":FILENAME:".email"
EXECUTE '!sendmail -f ':EMAIL:' -r ':EMAIL:' -t -Rfull < ':PATHTOMSG
CAPTURING OUTPUT RETURNING OUTPUT2
Glen
http://mvdevcentral.com
http://picksource.com
I'll second using mutt. I use it to send PDF and FDF documents directly
out of our D3/aix system. mutt answered the question, "how do I send
attachments" very nicely.
Art
John,
We do exactly what you are wanting to do and it is very easy. If you
send a binary file through Sendmail/Postfix etc. you will notice that
it gets sent as an attachment where a text file will end up as the body
of the email. We use uuencode to convert the pdf files into a binary
and then email the binary file. Uuencode is generally on a Linux
system's install disks, but often is not installed automatically. Check
/usr/bin and see if it is there first. Man pages should help you do the
rest.
Good Luck,
Scott
It may be overkill, but you can look at mutt
--
-----------------------------------------------------------------------------
Usenet Poster
use...@gnubin.com
-----------------------------------------------------------------------------
> I believe it was jo...@mrpsystems.co.uk who said...
>>
>> However, sending PDF files, or any type of file in essence, requires
>> they be sent as "attachments". This is where I am stuck !!!
>>
>> Can anyone guide me as to what I need to do in terms of the EMAIL /
PDF
>> file genration before using "sendmail" etc.
>
> It may be overkill, but you can look at mutt
>
If you are still having problems, here is a small shell script that we
wrote to take UniVerse printing output and merge it into a pdf file with
a pre-generated pdf invoice masking. We set up a virtual printer in
UniVerse and call this script as the printer driver. You will need to
have pdf toolkit installed on the Linux machine.
cat - |lp -c -d lp99
# lp99 is a virtual Linux postscript printer that we have setup to write
to
# file. It writes to /usr/spool/uv/pdfspool.ps
sleep 1
# we put a small delay in here so that the file has time to be created.
ps2pdf /usr/spool/uv/pdfspool.ps /usr/spool/uv/pdfout.pdf
# ps2pdf converts the postscript file to a pdf file
pdftk pdfout.pdf output art.pdf background NATINVOICE.pdf
# pdftk takes the pdf file and merges it with the pre-existing blank
# invoice -->NATINVOICE.pdf to a final file called art.pdf
/usr/bin/uuencode art.pdf invoice.pdf >inv.pdf
# uuencode encodes the art.pdf file to a binary called inv.pdf. When
# the end user receives it in his/her email it will be extracted as
# invoice.pdf
mail -s 'Invoice' email@address.1 email@address.2 <inv.pdf
# we use the mail command to send the file. Sendmail works as well.
I hope this helps,
Scott