<?
	// http://127.0.0.1/fiskal-x/svn-server/ugo-web/iso/mailing.php
	
	
	// http://davidwalsh.name/send-files-ftp-php
	// http://php.net/manual/en/function.ftp-put.php
	
	$file = '../res/files/stanje_skladista.pdf';
	$remote_file = 'httpdocs/stanje_skladista_12345.pdf';
	
	// set up basic connection
	$conn_id = ftp_connect('host-ip-address');
	
	// login with username and password
	$login_result = ftp_login($conn_id, 'login', 'passssssss');
	
	// upload a file
	if(ftp_put($conn_id, $remote_file, $file, FTP_BINARY)){
		echo "successfully uploaded $file\n";
	}else{
		echo "There was a problem while uploading $file\n";
	}
	
	// close the connection
	ftp_close($conn_id);
	
	
	
	/*
	http://swiftmailer.org/download
	http://stackoverflow.com/questions/712392/send-email-using-the-gmail-smtp-server-from-a-php-page?rq=1
	*/
	
	
	
	/*
		http://stackoverflow.com/questions/11801013/how-to-send-emails-with-php-using-the-pear-mail-package-with-attachment
	*/
	
	/**
		*  
		* @param type $recipient
		* @param type $subject
		* @param type $message
		* @param type $attachment
		*  
		* To make this mail PEAR work, I needed to do:
		* pear install mail
		* pear install Net_SMTP
		* pear install Mail_Mime
		* 
	*/

	/*
	public function sendmail($recipient, $subject, $message, $attachment = '') {
		require_once "Mail.php";
		require_once "Mail/mime.php";
		
		$from = "Dispatcher <server@mymailserver.com>";
		$host = "smtp.mymailserver.com";
		$port = "587";
		$username = "mailuser";
		$password = "password";
		
		$headers = array ('From' => $from, 'To' => $recipient, 'Subject' => $subject);
		
		if($attachment != ''){
			$crlf = "\n";
			$mime = new Mail_mime($crlf);
			$mime->setTXTBody($message);
			$mime->addAttachment($attachment, 'application/pdf');
			$body = $mime->get();
			$headers = $mime->headers($headers);
		}else{
			$body = $message;
		}
		
		$smtp = Mail::factory('smtp',
			array ('host' => $host,
				'port' => $port,
				'auth' => true,
				'username' => $username,
				'password' => $password));
		
		$smtp->send($recipient, $headers, $body);
	}
	*/

	
	
	
	
	
?>