Hi, I'm at least getting an email, however the attachment isn't being attached. Originally this email was working fine with sendmail. I'm on a windows server that doesn't have sendmail apparantely so I'm using SMTP to send the email. This is what arrives in my email:
1001du.txt Content-Transfer-Encoding: binary Content-Type: multipart/mixed; boundary="boundary-144416012012" MIME-Version: 1.0 Date: 144416012012 From: sking@mortgage-pros.com To: admin@mortgagerefinancingpros.com Subject: New loan request in database (extra fields) This is a multi-part message in MIME format. --boundary-144416012012 Content-Disposition: inline Content-Length: 271 Content-Transfer-Encoding: binary Content-Type: text/plain Dear Member, Please find attached to this email message a loan application file fro +m a recent loan applicant. Be sure to save this DU 3.2 file to your +hard drive and import the data into your loan processing program. Regards, Site Administration Mortgage-pros.com --boundary-144416012012 Content-Disposition: inline; filename="1001du.txt" Content-Transfer-Encoding: base64 Content-Type: application/zip; name="1001du.txt" MTAwMWR1LnR4dA== --boundary-144416012012--
Here's the code:
sub sendfile { my $email = $_[0]; my $from = $_[1]; my $subject = $_[2]; my $message = $_[3]; my $file = $_[4]; ($date,$boundary) = &boundary; #print "Content-type: text/html\n\n"; #print $_[4]; #exit; my $file_cont=encode_base64($file); #my $file_cont=encode_base64($line); $length=length($message); $send = qq~Content-Transfer-Encoding: binary Content-Type: multipart/mixed; boundary="$boundary" MIME-Version: 1.0 Date: $date From: $from To: $email Subject: $subject This is a multi-part message in MIME format. --$boundary Content-Disposition: inline Content-Length: $length Content-Transfer-Encoding: binary Content-Type: text/plain $message --$boundary Content-Disposition: inline; filename="$file" Content-Transfer-Encoding: base64 Content-Type: application/zip; name="$file" $file_cont --$boundary-- ~; $smtp = Net::SMTP->new($mailhost); $smtp->mail($_[1]); $smtp->to($_[0]); $smtp->data(); $smtp->datasend("To: $_[0]\n"); $smtp->datasend("From: $_[1]\n"); $smtp->datasend("Subject: $_[2]\n\n"); $smtp->datasend("\n"); #$smtp->datasend("$_[3]\n"); $smtp->datasend("$_[4]\n"); $smtp->datasend("$send\n"); $smtp->dataend(); $smtp->quit; # open(MAIL,"|$mailprog -t"); # print MAIL $send; # close(MAIL); }

In reply to mail script with attachment by zlinkexchange

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.