<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Attaching file(s) to sendmail in cgi in Operating System - OpenVMS</title>
    <link>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060646#M31003</link>
    <description>If your intention is only to send SMTP mail with file attachments from a Unix box, perhaps you would consider grabbing the following tool:&lt;BR /&gt;[Compaq C] Example-C,C++ SMTP Mail Message Sender With MIME File Attachments &lt;BR /&gt;available at the following URL:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h18000.www1.hp.com/support/asktima/communications/009F15E8-A8CE0B38-1C02A1.html" target="_blank"&gt;http://h18000.www1.hp.com/support/asktima/communications/009F15E8-A8CE0B38-1C02A1.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I tested the program on Tru64, HP-UX, Linux and Sun Solaris. Its use ought to be simple.&lt;BR /&gt;Hoping this can help you.</description>
    <pubDate>Wed, 01 Oct 2003 07:08:32 GMT</pubDate>
    <dc:creator>Vouters</dc:creator>
    <dc:date>2003-10-01T07:08:32Z</dc:date>
    <item>
      <title>Attaching file(s) to sendmail in cgi</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060643#M31000</link>
      <description>Hi, I'm in a CGI script and have got to the point where I want to send a mail using sendmail (which works btw), and I know which file(s) I want to send with the email (and have also uploaded them to Unix server).&lt;BR /&gt;&lt;BR /&gt;The problem I have now is not knowing how to actually attach the file(s) to sendmail using the code I have below I can't get it to work, any ideas?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;code:-----------------------------------------&lt;BR /&gt; open (MAIL, "|$mailProgram -f 'webserver' -F '$email_from' '$mailTo");&lt;BR /&gt; &lt;BR /&gt;  print "in mail loop so file is open";&lt;BR /&gt;  &lt;BR /&gt;  print "\nsend to [$mailTo]";&lt;BR /&gt;  print "\nfilename [$xmlfilename]";&lt;BR /&gt;  &lt;BR /&gt;  print MAIL "To: $mailTo\n";&lt;BR /&gt;  print MAIL "From: webserver\n";&lt;BR /&gt;  print MAIL "Subject: Support Request Form Results\n\n";&lt;BR /&gt;  &lt;BR /&gt;  # for each filename (later)&lt;BR /&gt;  open (XMLFILE, "&amp;lt;$xmlfilename");&lt;BR /&gt;  &lt;BR /&gt;   while (&lt;XMLFILE&gt; )&lt;BR /&gt;   {&lt;BR /&gt;    print MAIL $_;&lt;BR /&gt;   }  &lt;BR /&gt;   &lt;BR /&gt;  close (XMLFILE);&lt;BR /&gt;  &lt;BR /&gt;  # now add attachments&lt;BR /&gt;  print MAIL "uuencode $xmlfilename";&lt;BR /&gt;  &lt;BR /&gt; close (MAIL);&lt;BR /&gt;----------------------------------------------&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I appreciate the test is only for one file at the moment, and for now, I'm sending to Microsoft Outlook, but only to test really, will be using pegasus mail on secure unix server so assume I'd have to duencode, appreciate the help&lt;BR /&gt;&lt;BR /&gt;p.s. have already tried different variations of the uuencode but as yet, no success :(&lt;/XMLFILE&gt;</description>
      <pubDate>Mon, 01 Sep 2003 08:53:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060643#M31000</guid>
      <dc:creator>Jimmy_37</dc:creator>
      <dc:date>2003-09-01T08:53:23Z</dc:date>
    </item>
    <item>
      <title>Re: Attaching file(s) to sendmail in cgi</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060644#M31001</link>
      <description>Since you appear to be using Perl, there are much better ways to do this than opening a pipe to sendmail.  I think the MIME::Lite extension is the easiest -- see the example below.  BTW, if you are doing this on a UNIX server, why did you post the question in an OpenVMS forum?  In any case, MIME::Lite works on any platform Perl works on.&lt;BR /&gt;&lt;BR /&gt;#perl&lt;BR /&gt;&lt;BR /&gt;use MIME::Lite;&lt;BR /&gt;&lt;BR /&gt;MIME::Lite-&amp;gt;send('smtp', "smtp.mydomain.com", Timeout=&amp;gt;60);&lt;BR /&gt;&lt;BR /&gt;$file = shift @ARGV;&lt;BR /&gt;$recipients = shift @ARGV;&lt;BR /&gt;&lt;BR /&gt;$subject = 'This message tests attachment reception [octet-stream].';&lt;BR /&gt;$message = "The attachment should be named $file\n";&lt;BR /&gt;&lt;BR /&gt;    if (&amp;amp;mail_file( $file, $recipients, $subject, $message ))&lt;BR /&gt;    {&lt;BR /&gt;        print "Mailed $file to $recipients.\n";&lt;BR /&gt;&lt;BR /&gt;    }&lt;BR /&gt;    else&lt;BR /&gt;    {&lt;BR /&gt;        print "Error mailing $file to $recipients\n";&lt;BR /&gt;        $error_count++;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;exit;&lt;BR /&gt;&lt;BR /&gt;#-------------------------------------------------------------------------------&lt;BR /&gt;# This routine actually mails the file as an attachment using base64 encoding.&lt;BR /&gt;&lt;BR /&gt;sub mail_file&lt;BR /&gt;{&lt;BR /&gt;    my ($path, $recipients, $subject, $message) = @_;&lt;BR /&gt;&lt;BR /&gt;    # Create a new message object.&lt;BR /&gt;&lt;BR /&gt;    my @recipient_list = split( /,\s*/, $recipients );&lt;BR /&gt;&lt;BR /&gt;    my $msg = new MIME::Lite&lt;BR /&gt;                From    =&amp;gt;$ENV{USER},&lt;BR /&gt;                To      =&amp;gt;\@recipient_list,&lt;BR /&gt;                Subject =&amp;gt;$subject,&lt;BR /&gt;                Type    =&amp;gt;'TEXT',&lt;BR /&gt;                Encoding=&amp;gt;'quoted-printable',&lt;BR /&gt;                Data    =&amp;gt;$message;&lt;BR /&gt;&lt;BR /&gt;    my $filename = $path;&lt;BR /&gt;&lt;BR /&gt;    if ($path)&lt;BR /&gt;    {&lt;BR /&gt;            # Attach a file to the message.&lt;BR /&gt;&lt;BR /&gt;            attach $msg Type     =&amp;gt;'application/octet-stream',&lt;BR /&gt;                Path     =&amp;gt;$path,&lt;BR /&gt;                Filename =&amp;gt;$filename,&lt;BR /&gt;                Encoding =&amp;gt;'base64',&lt;BR /&gt;                Disposition =&amp;gt;'attachment';&lt;BR /&gt;    }&lt;BR /&gt;    return $msg-&amp;gt;send;&lt;BR /&gt;}&lt;BR /&gt;</description>
      <pubDate>Mon, 01 Sep 2003 14:09:35 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060644#M31001</guid>
      <dc:creator>Craig A Berry</dc:creator>
      <dc:date>2003-09-01T14:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Attaching file(s) to sendmail in cgi</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060645#M31002</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I do almost perfectly agree with Craig ;-)&lt;BR /&gt;&lt;BR /&gt;First you really would be better off in a Unix forum (OpenVMS does not use sendmail for SMTP services). E.g. &lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/cm/CategoryHome/1,,150,00.html" target="_blank"&gt;http://forums.itrc.hp.com/cm/CategoryHome/1,,150,00.html&lt;/A&gt;&lt;BR /&gt;might be appropriate (this is the hp-ux languages section).&lt;BR /&gt;&lt;BR /&gt;Now, as to the solution to your problem, I quote the Perl motto "There is more than one way to do it", so I suggest the Mail::Sender Module rather than MIME::Lite since you do not have to bother about encoding the stuff yourself, the right form will be chossen automatically for you. I do use this module daily in a production environment to sent out both textual and binary file attachments.&lt;BR /&gt;&lt;BR /&gt;Check  &lt;A href="http://search.cpan.org/author/JENDA/Mail-Sender-0.8.08/" target="_blank"&gt;http://search.cpan.org/author/JENDA/Mail-Sender-0.8.08/&lt;/A&gt;&lt;BR /&gt;for the module.&lt;BR /&gt;&lt;BR /&gt;Greetings, Martin &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 01 Sep 2003 16:36:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060645#M31002</guid>
      <dc:creator>Martin P.J. Zinser</dc:creator>
      <dc:date>2003-09-01T16:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Attaching file(s) to sendmail in cgi</title>
      <link>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060646#M31003</link>
      <description>If your intention is only to send SMTP mail with file attachments from a Unix box, perhaps you would consider grabbing the following tool:&lt;BR /&gt;[Compaq C] Example-C,C++ SMTP Mail Message Sender With MIME File Attachments &lt;BR /&gt;available at the following URL:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://h18000.www1.hp.com/support/asktima/communications/009F15E8-A8CE0B38-1C02A1.html" target="_blank"&gt;http://h18000.www1.hp.com/support/asktima/communications/009F15E8-A8CE0B38-1C02A1.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I tested the program on Tru64, HP-UX, Linux and Sun Solaris. Its use ought to be simple.&lt;BR /&gt;Hoping this can help you.</description>
      <pubDate>Wed, 01 Oct 2003 07:08:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-openvms/attaching-file-s-to-sendmail-in-cgi/m-p/3060646#M31003</guid>
      <dc:creator>Vouters</dc:creator>
      <dc:date>2003-10-01T07:08:32Z</dc:date>
    </item>
  </channel>
</rss>

