CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
Snippet Name: Heavy-duty SendMail function
Description: A heavy-duty SendMail function
Also see: » Send iCal Email Meeting Requests using...
» Is email deliverable?
» Email attachments with PHP mail()
» Email w/ attachments class
» Use SendMail
» Automatically process email
» Live validation of email address
» Fake email addresses
» Validate email address #3
» Validate email address #2
» Validate email address #1
Comment: (none)
Language: PHP
Highlight Mode: PHP
Last Modified: March 16th, 2009
<?PHP
FUNCTION sendmail ( $from_name , $from_email , $to_name , $to_email , $subject , $text_message = "" , $html_message , $attachment = "" )
{
$from = "$from_name <$from_email >" ;
$to = "$to_name <$to_email >" ;
$main_boundary = "----=_NextPart_" . MD5 ( RAND ( ) ) ;
$text_boundary = "----=_NextPart_" . MD5 ( RAND ( ) ) ;
$html_boundary = "----=_NextPart_" . MD5 ( RAND ( ) ) ;
$headers = "From: $from \n " ;
$headers .= "Reply-To: $from \n " ;
$headers .= "X-Mailer: Yellow\n " ;
$headers .= "MIME-Version: 1.0\n " ;
$headers .= "Content-Type: multipart/mixed;\n \t boundary=\" $main_boundary \" \n " ;
$message .= "\n --$main_boundary \n " ;
$message .= "Content-Type: multipart/alternative;\n \t boundary=\" $text_boundary \" \n " ;
$message .= "\n --$text_boundary \n " ;
$message .= "Content-Type: text/plain; charset=\" ISO-8859-1\" \n " ;
$message .= "Content-Transfer-Encoding: 7bit\n \n " ;
$message .= ( $text_message != "" ) ?"$text_message " : "Text portion of HTML Email" ;
$message .= "\n --$text_boundary \n " ;
$message .= "Content-Type: multipart/related;\n \t boundary=\" $html_boundary \" \n " ;
$message .= "\n --$html_boundary \n " ;
$message .= "Content-Type: text/html; charset=\" ISO-8859-1\" \n " ;
$message .= "Content-Transfer-Encoding: quoted-printable\n \n " ;
$message .= STR_REPLACE ( "=" , "=3D" , $html_message ) . "\n " ;
IF ( ISSET ( $attachment ) && $attachment != "" && COUNT ( $attachment ) >= 1 )
{
FOR ( $i = 0 ; $i < count ( $attachment ) ; $i ++ )
{
$attfile = $attachment [ $i ] ;
$file_name = BASENAME ( $attfile ) ;
$fp = FOPEN ( $attfile , "r" ) ;
$fcontent = "" ;
WHILE ( ! FEOF ( $fp ) )
{
$fcontent .= FGETS ( $fp , 1024 ) ;
}
$fcontent = CHUNK_SPLIT ( BASE64_ENCODE ( $fcontent ) ) ;
@ FCLOSE ( $fp ) ;
$message .= "\n --$html_boundary \n " ;
$message .= "Content-Type: application/octetstream\n " ;
$message .= "Content-Transfer-Encoding: base64\n " ;
$message .= "Content-Disposition: inline; filename=\" $file_name \" \n " ;
$message .= "Content-ID: <$file_name >\n \n " ;
$message .= $fcontent ;
}
}
$message .= "\n --$html_boundary --\n " ;
$message .= "\n --$text_boundary --\n " ;
$message .= "\n --$main_boundary --\n " ;
@ MAIL ( $to , $subject , $message , $headers ) ;
}
?>
SQL University.net courses meet the most demanding needs of the business world for advanced education
in a cost-effective manner. SQL University.net courses are available immediately for IT professionals
and can be taken without disruption of your workplace schedule or processes.
Compared to traditional travel-based training, SQL University.net saves time and valuable corporate
resources, allowing companies to do more with less. That's our mission, and that's what we deliver.
Click here to find out more
117 users online
© 2009 psoug.org