Page 1 of 1

Emailing attachments with PHP....

Posted: Sun May 26, 2002 9:24 pm
by Hebbs
Morning (?) all.

I have a script that forwards an email reply to users with the option of adding an attachment to that mail.

It all works beauthifully with one exception.

I can only add attachments that are physically located on the server.

I am operating within a secure LAN and when I add the attachment from anywhere other than the server it fails to send.

For security reasons I dont want to open access to the server so need to figure this one out, hopefully someone out there has come across this before.

This is an example of what Im using (I have left out the body of the email to save space):

Code: Select all

$mail = new phpmailer();
		$mail->IsSMTP();								// set mailer to use SMTP
		$mail->Helo = $PROGRAMNAME." phpclient";
		$mail->UseMSMailHeaders = on;
		$mail->From = $BCIMAIL; 
		$mail->FromName = $CSMAILNAME; 
		$mail->Host = $SMTP_SERVER;	
		$mail->AddAddress($req_emailto, $emailreqname); 
		$mail->Priority = 1; 
		$MESSAGEID2	 = "Message-ID: <".md5(uniqid(time())).".".$BCIMAIL.">";
		$mail->AddCustomHeader($MESSAGEID2);
		$mail->AddCustomHeader($XSYSTEM);
		$mail->AddReplyTo($BCIMAIL, $CSMAILNAME); 
		$mail->WordWrap = 50;							// set word wrap to 50 characters
		$mail->IsHTML(true);							// set email format to HTML
		$mail->Subject = $subjectline;
		if ($resultmethod  == "Hardcopy") &#123;
			$mail->Body    = ("Email text");
		&#125;
		elseif ($resultmethod  == "Electronic") &#123;
			$mail->Body    = ("Email text");
			$mail->AddAttachment("$fn");  // optional name
		&#125;
Any thoughts?

Hebbs

Posted: Sun May 26, 2002 9:58 pm
by Benjamin
write a script which will get the file from the user and then save it to a temporary directory on the server, once the message has been sent, have the script delete the file.

Posted: Mon May 27, 2002 3:06 am
by Hebbs
Thanks for that,

Have you an example of how to do this?

I need the user to be able to path to the right network drive, select the file and then have it save in a temporary location. ALl prior to sending.

Am reasonably new to this game and would appreciate your help or perhaps pointing me in the right direction.

Regareds

Hebbs