1
mramsey
Adding Email Attachments
  • 2005/5/6 6:52

  • mramsey

  • Just popping in

  • Posts: 33

  • Since: 2002/3/8 3


I am having a fair bit of trouble figuring out how to send attachments via email. Those familiar with these types of message source formats will know that I need to add a short line in to the headers and then encapsulate the file in to the body with a 'head' and 'foot'.

I have looked at the functions available in:

/class/xoopsmailer.php
and
/class/mail/xoopsmultimailer.php

Apparently xoopsmultimailer.php has a class called XoopsMultiMailer which 'extends' XoopsMultiMailer the same class found in:

/class/mail/phpmailer/class.phpmailer.php

I have read the docs for the base phpmailer and it looks like it has fairly sophisticated mail attachment functions which look as though they will do exactly what I need.

My question is, how should I go about accessing them through the standard email functions built in to XOOPS 2 (xoops 2.0.10)?

Currently I have:

$xoopsMailer =& getMailer();
$xoopsMailer->useMail();
$xoopsMailer->setToEmails($xoopsConfig['adminmail']);
$xoopsMailer->setFromEmail($xoopsConfig['adminmail']);
$xoopsMailer->setFromName($xoopsConfig['sitename']);
$xoopsMailer->setSubject($subject);
$xoopsMailer->setBody($message);

$xoopsMailer->send();

Which is working find, but i havent tried to attach anything yet...

$xoopsMailer->multimailer->AddStringAttachment($string, $attachment, "base64", "application/octet-stream");

In PHPMailer documentation they talk about this below;

Adds a string or binary attachment (non-filesystem) to the list.

This method can be used to attach ascii or binary data, such as a BLOB record from a database.

void AddStringAttachment (string $string, string $filename, [string $encoding = "base64"], [string $type = "application/octet-stream"])
string $string:
String attachment data.

string $filename:
Name of the attachment.

string $encoding:
File encoding (see $Encoding).

string $type:
File extension (MIME) type.

And that chich exactly what I need.

What could be the (string $string) to allow the form work?

Any ideas would be greatly appreciated

Login

Who's Online

411 user(s) are online (303 user(s) are browsing Support Forums)


Members: 0


Guests: 411


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits