Link to home
Start Free TrialLog in
Avatar of tankergoblin
tankergoblin

asked on

email notification

Hi,

how to create a basic email notificaton.

do i need an email server to do this?

can show me some code?
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

Basic PHP Mail Function:
http://php.net/manual/en/function.mail.php

If you are using a linux server or hosting platform (that uses Plesk or cPanel) you already have a mail server built in, and it should "just work"

If you are on Windows, you are asking for a headache. But, you can still do it. You need to enable the SMTP server in IIS.

See:
http://forums.iis.net/p/1157046/1901343.aspx
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e4cf06f5-9a36-474b-ba78-3f287a2b88f2.mspx?mfr=true
http://msdn.microsoft.com/en-us/library/8b83ac7t%28v=vs.100%29.aspx
ASKER CERTIFIED SOLUTION
Avatar of DrDamnit
DrDamnit
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
To find out if you've got it set up, you can use this script, shown here in its entirety.  Make the appropriate replacement for your email address, put it on your server and run it from a browser URL.

<?php error_reporting(E_ALL);
mail('you@your.org', 'EMAIL', 'TEST');

Open in new window

Avatar of asaidi
asaidi

Hi
the mail function was working perfect in my xp since i changed it to windows 7 prof i cannot configure smtp ..
i asked this question in php area as i thought somebody has the same problem..
it is win7 problem not php sorry
Avatar of tankergoblin

ASKER

im using exchange server. and i want to send a email notification when the form is submitted.

can some one show me the code. thank you.
In that case, you will need to configure exchange to accept unauthenticated mail (anonymous)from your sending server. Then use phpmailer to and mail to that box.
can you show me how to send email notification in code?
this is an email that i m using to send emails and emails  i m getting from my table

//-----------------------------------------------
     //DECLARE LES VARIABLES  ----
     //-----------------------------------------------

     $email_expediteur='info@email.com';
     $email_reply='ahmed.saidi21@gmail.com';
     $message_texte='Monthly Report,'."\n\n".'Hi '.$surname;--------i got from database

     $message_html='<html>
     <head>
     <title>Titre</title>
     </head>
     <body>Please find attached pdf monthly report,</body>
     </html>';

     //-----------------------------------------------
     //GENERE LA FRONTIERE DU MAIL ENTRE TEXTE ET HTML
     //-----------------------------------------------

     $frontiere = '-----=' . md5(uniqid(mt_rand()));

     //-----------------------------------------------
     //HEADERS DU MAIL
     //-----------------------------------------------

     $headers = 'From :<'.$email_expediteur.'>'."\n";
     $headers .= 'Return-Path: <'.$email_reply.'>'."\n";
     $headers .= 'MIME-Version: 1.0'."\n";
     $headers .= 'Content-Type: multipart/mixed; boundary="'.$frontiere.'"';

     //-----------------------------------------------
     //MESSAGE TEXTE
     //-----------------------------------------------
     $message = 'This is a multi-part message in MIME format.'."\n\n";
     $message .= '--'.$frontiere."\n";
     $message .= 'Content-Type: text/plain; charset="iso-8859-1"'."\n";
     $message .= 'Content-Transfer-Encoding: 8bit'."\n\n";
     $message .= $message_texte."\n\n";

     //-----------------------------------------------
     //MESSAGE HTML
     //-----------------------------------------------
     $message .= '--'.$frontiere."\n";
     $message .= 'Content-Type: text/html; charset="iso-8859-1"'."\n";
     $message .= 'Content-Transfer-Encoding: 8bit'."\n\n";
     $message .= $message_html."\n\n";
     $message .= '--'.$frontiere."\n";

     //-----------------------------------------------
     //PIECE JOINTE
     //-----------------------------------------------

     $message .= 'Content-Type: application/pdf; name=$surname'.'.pdf'."\n";
     $message .= 'Content-Transfer-Encoding: base64'."\n";
     $message .= 'Content-Disposition:attachement; filename="monthly.pdf"'."\n\n";

     $message .= chunk_split(base64_encode(file_get_contents($surname.'.pdf')))."\n";

     if(mail($email,'Monthly Report',$message,$headers))
     {
          echo 'Mail was sent to  '.$email.'<br/>';
     }
     else
     {
          echo 'mail failed...';
     }

Open in new window

i hope it is what you are looking otherwise you need to ask experts