Showing posts with label attachements. Show all posts
Showing posts with label attachements. Show all posts

Thursday, June 5, 2008

Sending an email from PHP (on Windows too.)

Yey, finally got something that really works.
It's not my stuff, but I was able to found it after a long time search!
Here is the link to sourceForge.net, to the page that hosts php Mailer for PHP 5 for Windows, and looks like for Unix too. If the link does not work then search for the word phpMailer.

The easiest way to install the stuff is to do as follows (example on Windows, with assumption that you have your php installed in the c:\php directory.)

> mkdir c:\php\mailer
Unzip phpMailer_v2.1.zip into c:\php\mailer
> notepad.exe c:\php\php.ini
Add at the very end:
include_path=".;c:\php\mailer"

Youre done!

Now, example:
>
<?php
require_once( "class.phpmailer.php" ) ;

$mail = new PHPMailer() ;
$mail->IsSMTP() ;
$mail->Host = "smtp.myserver.com:587" ;
$mail->SMTPAuth = true ;
$mail->Username = "username" ;
$mail->Password = "password" ;
$mail->From = "me@myserver.com" ;
$mail->FromName = "It is me!" ;
$mail->AddAddress( "testaddress@theirserver.com", "Poor Receiver" ) ;
$mail->AddReplyTo( "me@myserver.com", "do-not-reply" ) ;
$mail->AddAttachment( "c:\\mydog.jpg", "Isn't she cute?" ) ;
$mail->Subject = "Sorry for this test email!" ;
$mail->IsHTML( true ) ;
$mail->Body = file_get_contents( "c:\\myemail.html" ) ;
$mail->AltBody = "non-HTML mail client? Where are you from?" ;

if( !$mail->Send())
printf( "Sending Error: " . $mail->ErrorInfo . "\n" ) ;
else
printf( "Message has been sent successfully.\n" ) ;
?>

Wednesday, May 28, 2008

Opening unopenable attachments in Microsoft Outlook

The Microsoft Outlook software, starting, as I believe, from version 2003, turned opening some of the attachments for good. If you received, for example, an .mdb file (from Microsoft Access,) then you will only see that you got it, but you won't be able to copy it to the hard drive. Don't try searching in the options as suggested in the email. There is no option to turn the ability to detach the attachment on.
Microsoft says it clearly - because it is one of the most popular applications for managing emails, it has been constantly under attach by the hackers, so to 'save' their customers, they turned several options off for good. There is a workaround though. You can ask the sender to send you the file again, but ask him/her to rename the extension of the file or to zip/rar it. If such option is not a good one, or at least not for the very moment because you're in a hurry, there the following solution:

Run regedit: WARNING, WARNING: These operations are dangerous, so if you're not feeling secure, don't play with regedit. Screwing up in this file may screw up with your Windows installation and ultimatelly you may have to reinstall your OS!!!!

Open HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Security
(11.0 is for Outlook 2003)

Create or add a New String Value under this key with the name: Level1Remove

Enter the file extensions separated with the semicolon (;) that you would like to support in the attachment. The file extensions should start with a coma.

EXAMPLE:
Level1Remove .mdb;.xlsx

Typical errors:
- forgetting to put a dot in the front of the extension
- putting spaces into the Level1Remove value
- Putting Level1Remove string into improper place in registry
- Creating a KEY instead of a STRING VALUE in registry.

When you are done, close the regedit program, close your Microsoft Outlook application, and open it again. From that moment, the files with the extensions you have just added into registry will be available for you.

Make sure you don't overdo and don't add others files 'just in case'. You may put yourself in danger by allowing to accept .exe, .bat, .js and other executable files. Use your head!