/ collman/mail_accession.php
PHP | 197 lines | 81 code | 32 blank | 84 comment | 11 complexity | f0072ef430612f9935d98dda73ea3fa0 MD5 | raw file
- <?php
- //=========== HEADER STUFF ========
- $Title = "";
- $PageName = "";
- require ("ta_config.inc");
- require("ta_header.inc");
- require("ta_opendb.inc");
-
- echo "<h4>Acknowledging accession by e-mail</h4>";
-
- $accessionNumber =$_REQUEST['accessionNumber'];
- $donor = $_REQUEST['donor'];
- $sqlstring="Select names.email, names.lastName FROM accessions INNER JOIN names ON accessions.donor = names.name WHERE accessions.donor = '$donor'";
- $sql=mysqli_query($dbcnx,$sqlstring);
- if($row = mysqli_fetch_row($sql)){
- $recipient = "$row[0]";
- $lastname = "$row[1]";
- }
- else {
- echo "No kidding! This person does not have an e-mail"; //Should be fixed with AJAX on accession form itself!
- exit;
- }
-
- if($MAIL_SERVICE = "smtp") {
- ////////////////////////////////////
- // USING SMTP W/O AUTHORISATION //
- ////////////////////////////////////
-
- ini_set ('SMTP', $MAIL_SERVER );
-
- // The message
- $message = "Dear Dr. $lastname <br/> We gratefully acknowledge your donation of some dead fish, registered as Acccession $accessionNumber.<br/>Yours sincerely,<br/>$CURATOR.";
- echo wordwrap("<p>Acknowledgement email has been sent to $donor ($recipient):</p><p>$message</p>");
- // Your email address
- $myemail = $session->email;
-
- // The subject
- $subject = "Acknowledgement of receipt of $accessionNumber";
-
- //Send the mail
- mail($recipient, $subject, $message, "From: $myemail") or die("Unable to send message");
-
- //if all is well
- echo wordwrap("<p>Acknowledgement email has been sent to $donor ($recipient):</p><p>$message</p>",60);
-
- } // IF $MAIL_SERVICE = "smtp"
-
- if($MAIL_SERVICE == "sendmail") {
- /////////////////////////////////
- // USING LINUX WITH SENDMAIL //
- /////////////////////////////////
-
- ini_set('sendmail_path', $MAILSERVER);
-
- $accessionNumber =$_REQUEST['accessionNumber'];
- $donor = $_REQUEST['donor'];
-
- // Your email address
- $myemail = $session->email;;
-
- // The subject
- $subject = "Receipt of $accessionNumber";
-
- // The message
- $message = "Enter your message here";
-
- mail($recipient, $subject, $message, "From: $myemail");
-
- echo "The email has been sent.";
-
- } // if $MAIL_SERVICE = sendmail
-
-
- if ($MAIL_SERVICE == "Outlook") {
- ////////////////////////////////////////////////
- // Outlook variant in testing //
- // COM-Based outlook use for sending mail //
- // Adapted from tuturial by Bogomil Shopov //
- // http://www.howtodothings.com/computers/ //
- // a1059-how-to-send-e-mail-using-php //
- // -com-functions.html //
- ////////////////////////////////////////////////
- echo "Starting<br />";
- $objApp = new COM("Outlook.Application");
- $app->Visible = true;
- $namespace = $objApp->GetNamespace("MAPI");
- echo "Mapi<br />";
- $myItem = $objApp->CreateItem(olMailItem);
- echo "MailItem<br />";
- $a=$myItem->Recipients->Add("sven.kullander@nrm.se");
- echo "Add<br />";
- $myItem->Subject="This is a test";
- echo "Subject<br />",
- $myItem->Body="This is a Body Section now.....!";
- echo "Body<br />";
-
- // $attachments = $myItem->{"attachments"};
- // $attachment = $attachments->Add("c:\\perl\\progs\\outlook.pl");
-
- $myItem->Display();
- echo "Display<br />";
- $myItem->Send();
- echo "Sent<br />";
- } // IF $MAIL_SERVICE = Outlook
- /*
- The explanation
-
- $objApp = new COM("Outlook.Application");
-
- In the first line we create a instance of the COM object (in this case your
- Outlook Application)
-
- If you have installed MS Outlook, in your Windows registry exists a key named
- Outlook.Application
-
- Start Regedit.exe and explore the HKEY_CLASSES_ROOT . There is your Com objects.
-
- $myItem = $objApp->CreateItem(olMailItem);
-
- Creates new MailItem (new Mail)
-
- $a=$myItem->Recipients->Add("admin@purplerain.org");
-
- Adding the Recipient element of MailItem
-
- This will be your recipient
-
- $myItem->Subject="This
- is a test";
-
- Adding Subject element
-
- This will be your subject
-
- $myItem->Body="This is
- a Body Section now.....!";
-
- Adding the Body element of MailItem
-
- This will be your message
-
-
-
- $myItem->Display();
-
- If you want see your Outlook Mail dialog add this line in the script ,else just
- comment it!
-
- $myItem->Send();
-
- Send the message using your DEFAULT Outlook account.
- */
-
- if ($MAIL_SERVICE == "MAPI") {
- /////////////////////////////////
- // UNTESTED MAPI WITH EXCHANGE //
- /////////////////////////////////
- #New MAPI session...
- $session = new COM("MAPI.Session");
-
- #Login
- $strProfileInfo = "exchange_server" . chr(10) . "exchange_user";
- $session->Logon("", "", 0, 1, 0, 1, $strProfileInfo);
-
- # New message...
- $msg = $session->Outbox->Messages->Add();
- $msg->Subject = "Subject";
- $msg->Text = "body";
-
- #set recipients...
- $rcpts = $msg->Recipients;
- $rcpts->AddMultiple("toto@toto.com", 1); #To...
- $rcpts->AddMultiple("titi@titi.com", 2); #Cc...
- $rcpts->AddMultiple("tutu@tutu.com", 3); #Bcc...
-
- # Resolve senders
- $rcpts->Resolve();
-
- #Send message
- $msg->Send();
-
- #Logoff
- $session->Logoff();
-
- #Cleanup
- if($msg!=null) {
- $msg->Release();
- $msg = null;
- }
- if($session!=null) {
- $session->Release();
- $session = null;
- }
- } //if $MAIL_SERVICE=MAPI
-
-
- ?>