Using PHP:
function validate_email($email)
{
// - check for a invalid/false email address
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
// it failed the simple format test, so return with an invalid address error
return 1;
} else {
return 0; // send mail
}
}
// calls the email that was provided and parses it in the validate function
$valid = validate_email($email);
switch ($valid)
{
case 0:
//send the mail
mail ($email,"Subject",$message,$headers ) ;
case 1:
// show some error message
}
Using Javascript:
var result;
function checkemail()
{
var str=document.mailcheck.emailaddress.value;
var filter=/^.+@.+\..{2,3}$/;
if (filter.test(str))
result=true;
else
{
alert("Please input a valid email address!");
result=false;
}
return (result);
}
function checkall()
{
if (document.layers||document.all)
return checkemail();
else
return true;
}
Monday, June 16, 2008
Sending PDF as Attachment in Email Using PHP
$fileToSend = "myPDF.pdf"; //path to the PDF you want to send
$fileatttype = "application/pdf";
$file = fopen( $fileToSend, 'rb' );
$data = fread( $file, filesize( $fileToSend ) );
fclose( $file );
$semi_rand = md5( time() );
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers = "FROM:From Address Goes HERE!";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$data = chunk_split( base64_encode( $data ) );
$messageBody="This will be the Body of the email!";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$messageBody. "\n\n";
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatttype};\n" .
" name=\"{$fileToSend}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileToSend}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
//all set.. Now send the Email
mail ($email,"Subject Goes Here!",$message,$headers ) ;
$fileatttype = "application/pdf";
$file = fopen( $fileToSend, 'rb' );
$data = fread( $file, filesize( $fileToSend ) );
fclose( $file );
$semi_rand = md5( time() );
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers = "FROM:From Address Goes HERE!";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";
$data = chunk_split( base64_encode( $data ) );
$messageBody="This will be the Body of the email!";
$message = "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$messageBody. "\n\n";
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatttype};\n" .
" name=\"{$fileToSend}\"\n" .
"Content-Disposition: attachment;\n" .
" filename=\"{$fileToSend}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .
"--{$mime_boundary}--\n";
//all set.. Now send the Email
mail ($email,"Subject Goes Here!",$message,$headers ) ;
Sunday, June 1, 2008
New Features In Flash CS3
1. New Drawing Tools:
- a.Rectangle Primitive Tool
- b.Rectangle Oval Tool
- a. Import each Photoshop layer
- b. Text can remain editable while importing from Photoshop to Flash
Subscribe to:
Posts (Atom)