Jump to content

Using mail2 amd mime


gregaryb

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.

 

 <?php

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->setTXTBody($text);
$mime->setHTMLBody($html);
$mime->addAttachment($file, 'text/plain');

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

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

?> 

 

Link to comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...