Emailing attachments with PHP....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hebbs
Forum Commoner
Posts: 43
Joined: Mon Apr 22, 2002 9:34 pm
Location: Perth, Western Australia

Emailing attachments with PHP....

Post 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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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.
Hebbs
Forum Commoner
Posts: 43
Joined: Mon Apr 22, 2002 9:34 pm
Location: Perth, Western Australia

Post 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
Post Reply