Mailtraq Autoresponder with attached file

Articles and documents provided by support staff covering Mailtraq features and general operation.

Mailtraq Autoresponder with attached file

Postby Susan Bunbury » Fri Aug 26th, 2005 4:23pm

Problem:

You want to trigger an autoresponse script to send a jpg image (pic.jpg) to the sender of the email.

Solution:

You cannot attach a binary file to a mail message without encoding it
using base64 (because mail is a 7bit environment, not 8bit or binary).

Rather than use code, the simplest method of achieving what you want is to send yourself a message with the jpg file attached and paste all the required elements directly from it into your autoresponse.

Before collecting it from your mailbox (or from your inbound archive, if you have one), open \database\mail\inbox\user.afv in your text editor. The crucial elements you need in your autoresponder are ...

  • The MIME headers
  • The MIME entity headers
  • The base64 encoded .jpg file

You'll be sending a multipart/mixed MIME message; the first entity of which will be 7bit text/plain containing your text, the second entity will be image/jpeg in base64.

You should find something like the following. These two lines must be in the message headers ...

Code: Select all
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="_=_=_=_="

... then the message body starts like this ...

Code: Select all
 
 --_=_=_=_=
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 In response to your message :-
 <snip>

... followed by the base64 entity ...

Code: Select all
 --_=_=_=_=
 Content-Type: image/jpeg; name=pic.jpg
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment; filename=pic.jpg
 
 /9j/4AAQSkZJRgABAgEASABIAAD/4ABKQ3J1dGNoZmllbGQAQ29weXJpZ2h0IDIwMDIgQ3J1dGNo
 < big snip, leaving only first and last lines >
 0UHVVFcq0UHVVFcq0UHVVFcq0UHVVFcq0UHVVFcq0UHVVFcq0UHVVFcq0UH/2Q==
 
 --_=_=_=_=--

Putting all that together ...

Code: Select all
 {
   description := GetSystemVar("/mailslots/" ++ MAILBOX ++ "/Description");
   SelectOutMessage();
   SetHeader("Subject", "Automatic Reply from " ++ description);
   SetHeader("MIME-Version", "1.0")
   SetHeader("Content-Type", "multipart/mixed; boundary=\q_=_=_=_=\q")
   SelectInMessage()
 }
 
 --_=_=_=_=
 Content-Type: text/plain; charset=us-ascii
 Content-Transfer-Encoding: 7bit
 
 In response to your message :-
 
   { Header("Subject") } on { Header("Date") }
 
 There is a photo attached to this email
 
 
 --_=_=_=_=
 Content-Type: image/jpeg; name=pic.jpg
 Content-Transfer-Encoding: base64
 Content-Disposition: attachment; filename=pic.jpg
 
 /9j/4AAQSkZJRgABAgEASABIAAD/4ABKQ3J1dGNoZmllbGQAQ29weXJpZ2h0IDIwMDIgQ3J1dGNo
 <big snip, leaving only first and last lines>
 0UHVVFcq0UHVVFcq0UHVVFcq0UHVVFcq0UHVVFcq0UHVVFcq0UHVVFcq0UH/2Q==
 
 --_=_=_=_=--

Mailtraq will simply deliver the autoresponse as though the whole thing is
pure text, which it is, really, after being encoded.
Best wishes,
Susan

Sales and Initial Support
Enstar Mailtraq
User avatar
Susan Bunbury
Mailtraq Enstar Sales and Support
 
Posts: 359
Joined: Mon Aug 22nd, 2005 3:09pm
Location: CT, USA

Return to Mailtraq Knowledgebase and FAQ

Who is online

Users browsing this forum: No registered users and 1 guest

cron