Jump to content

Using mail2 amd mime

Recommended Posts

My attempt to use PHPMail has failed since I have no idea how to install a github library in CPANEL.

It seems as though CPANEL is wedded to PEAR package and mail2 and mime php libraries are available as PEAR packages and easy to install.

And they seem to do more or less the same job as PHPMail.

However how the buggery do you make them work????

If I insert any of this sample code in my web page I get various errors about unable to open streams due to the include statements or unknown identifiers (e.g. Mail_mime) if I leave out the include statements.



include 'Mail.php';
include 'Mail/mime.php' ;

$text = 'Text version of email';
$html = '<html><body>HTML version of email</body></html>';
$file = '/home/richard/example.php';
$crlf = "\n";
$hdrs = array(
              'From'    => 'you@yourdomain.com',
              'Subject' => 'Test mime message'

$mime = new Mail_mime(array('eol' => $crlf));

$mime->addAttachment($file, 'text/plain');

$body = $mime->get();
$hdrs = $mime->headers($hdrs);

$mail =& Mail::factory('mail');
$mail->send('postmaster@localhost', $hdrs, $body);



Link to post
Share on other sites

That means that it can't find the pear packages for whatever reason.

You don't really need to install PHPMailer, just upload the files with your code and include them.  There's a button to download the zip package on the GitHub page, you need to upload the files inside the src directory, include the main PHPMailer class file in your code, and you can use it.  They have instructions for installing with composer and whatever else but that's just overcomplicated.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...