php - smtp pear Mail.php include
this may be a simple one but im confused now. I basicly using the same frame work which i built for a previouse project and changing the 开发者_运维问答skin.
I have tried to test the email function but has failed to work, this is the error:
Warning: require_once() [function.require-once]: open_basedir restriction in effect. File(../../../../php/Mail.php) is not within the allowed path(s): (/home/amatoita:/usr/lib/php:/usr/local/lib/php:/tmp)
for some reason It seems like im not allowed here???
so i tried
/usr/lib/php/Mail.php
/home/amatoita/php/Mail.php
/usr/local/lib/php/Mail.php
which threw the following error:
Failed opening required 'Mail/mimePart.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/amatoita/php/Mail/mime.php
can anyone see where i am going wrong?
I was able to fix this issue by following the PEAR install directions at Mark's Tech Stuff blog.
My problem was that the Mail module of pear is not included in a standard Fedora install.
Then I used some code from the PEAR site.
<?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);
?>
Now my email gets sent in HTML just fine. Hope that helps you.
You'd need to have that package installed in one of the directories listed in the include_path. That means (most likely), you'd want it to be:
/home/amatoita/php/Mail.php
and have the mimePart.php in
/home/amatoita/php/Mail/mimepart.php
精彩评论