Hi there,
does anyone know why, when I try to attach a file to an email (created and sent via a php script) it won't work if the file is NOT on the same machine as the script?
If my script is on a machine called STELLA:
This doesn't work:
$filename = 'http://www.orchardsweb.com/commonpics/mail.gif';
This does:
$filename = 'mail.gif';
any ideas how I can reference the machine that contains the file so that the script will work?
thanks - dunstan orchard
p.s. I'm using the following script (which works perfectly because the file is on the same machine as the script):
<?
function reloadnow() {
global $PHP_SELF;
exit(); }
if(isset($submit)):
echo "hello";
echo "<br>";
echo $recipientmail;
echo "<br>";
echo $recipient;
echo "<br>";
echo $sendermail;
echo "<br>";
echo $sender;
echo "<br>";
echo $subjectline;
echo "<br>";
echo $filepath;
/************************************
Title.........: HTML Mime Mail class
Version.......: 1.33
Author........: Richard Heyes <richard.heyes@heyes-computing.net>
Filename......: example.php3
Last changed..: 24/10/2000
Notes.........: Based upon mime_mail.class
by Tobias Ratschiller <tobias@dnet.it>
and Sascha Schumann <sascha@schumann.cx>.
************************************/
error_reporting(63);
include('class.html.mime.mail.inc');
/***************************************
** Read the file background.gif into $attachment.
***************************************/
$filename = 'mail.gif';
$attachment = fread($fp = fopen($filename, 'r'), filesize($filename));
fclose($fp);
/***************************************
** Create the mail object. Optional headers
** argument. Do not put From: here, this
** will be added when $mail->send
** Does not have to have trailing \r\n
** but if adding multiple headers, must
** be seperated by \r\n.
***************************************/
$mail = new html_mime_mail('X-Mailer: Html Mime Mail Class');
/***************************************
** This is used to add an attachment to
** the email.
***************************************/
$mail->add_attachment($attachment, 'mail.gif', 'image/gif');
/***************************************
** Set Character Set
***************************************/
$mail->set_charset('iso-8859-1', TRUE);
/***************************************
** Builds the message.
***************************************/
$mail->build_message();
/***************************************
** Sends the message. $mail->build_message()
** is seperate to $mail->send so that the
** same email can be sent many times to
** differing recipients simply by putting
** $mail->send() in a loop.
***************************************/
$mail->send($recipient, $recipientmail, $sender, $sendermail, $subjectline);
reloadnow();
else:
?>
<form METHOD="POST" ACTION="<?=$PHP_SELF;?>">
Please enter your details:
<br>
name: <input type="text" name="sender" style="font-size:10px;">
email: <input type="text" name="sendermail" style="font-size:10px;">
<br>
<br>
Please enter the recipients details:
<br>
name: <input type="text" name="recipient" style="font-size:10px;">
email: <input type="text" name="recipientmail" style="font-size:10px;">
<br>
<br>
file: <input name="filepath" type="file" style="font-size:10px;">
<br>
subject: <input type="text" name="subjectline" style="font-size:10px;">
<INPUT TYPE="submit" NAME="submit" VALUE="submit" style="font-size:10px;">
</form>
<?
endif;
?>