1

Need to send email using PHP via lotus notes. Notes is configured on my system. So just wanted if I could send email using PHP. Can anybody help with the code and configuration that I am supposed to do?


After reading replies from all of you, I tried to nail down things from my end. I could at least move one step ahead with all your help. I could figure out my mail server using GetEnvironmentString and its damn correct as also reflected in my lotus notes work space. But when I am trying to use the below code it just keeps on loading and finally returning nothing -

<?php

       require_once "Mail.php";

        $from = "abc@email.com";
        $to = "abc@email.com";
        $subject = "Test!";
        $body = "Hi,\n\nTest?";

        $host = "d23abcd";
        $port = "1352";
        $username = "abc@email.com";
        $password = "mypassword";

        $headers = array ('From' => $from,
          'To' => $to,
          'Subject' => $subject);
        $smtp = Mail::factory('smtp',
          array ('host' => $host,
            'port' => $port,
            'auth' => true,
            'username' => $username,
            'password' => $password));

        $mail = $smtp->send($to, $headers, $body);

        if (PEAR::isError($mail)) {
          echo("<p>" . $mail->getMessage() . "</p>");
         } else {
          echo("<p>Message successfully sent!</p>");
         }

    ?> 

Am I committing some mistake here? I doubt

 $host = "d23abcd";
 $port = "1352";
Per Henrik Lausten
  • 20,229
  • 3
  • 24
  • 72
anujin
  • 745
  • 7
  • 24
  • 36
  • No matter what your situation, I very much doubt you *need* to send email using PHP via Lotus Notes. Moreover, I very much doubt that it would ever be a good idea. – lonesomeday May 26 '12 at 13:39
  • Well, I have developed a small web application using PHP. My requirement is that when anyone submits a request on one of the pages, an email is triggered. As I can use only Notes as official id, so need to trigger email in notes. BTW, is it not viable using PHP? What is the reason for your doubts? – anujin May 26 '12 at 13:58

3 Answers3

3

If your Lotus Domino server has SMTP set up, you can use the Domino server as outgoing mail server (if PHP is able to send mail using a relay server).

Per Henrik Lausten
  • 20,229
  • 3
  • 24
  • 72
  • Sorry for asking this silly question but how to know if its SMTP enabled or not? Is there a way I myself can figure it out? And if its not, what is the other way? @lonesomeday - I got ur point buddy. Infact I was wrong in the way that I need not Notes but some mail server. – anujin May 26 '12 at 18:37
  • You can see if you can access SMTP on the server by telnetting to the server's hostname on port 25. Or ask your admin guys :-) If SMTP is not running on the Domino server, they might be able to help you with the address of another SMTP server. – Per Henrik Lausten May 26 '12 at 19:49
  • so i could see server name under workspace in my lotus notes. I pinged it and it responded. But getting the same error if I use server and port number even - PHP Warning: mail() [function.mail]: Failed to connect to mailserver at "serv123" port 552, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in ..htdocs\\automationutil\\pages\\sendemail.php on line 7 – anujin May 28 '12 at 09:45
  • i tried 25 only. but when it didnt work, identified the port and then tried ....but no luck – anujin May 28 '12 at 15:39
  • Contact your server admin and ask if SMTP is enabled on the server. – Per Henrik Lausten May 29 '12 at 05:23
  • well i tried quite a bit but have given up....ther sever reflected in my workspace under lotus notes doesn't work using php...so will use java .....huhhh :( – anujin May 29 '12 at 14:07
1

Thanks a bunch for all your responses and replies. Finally, I am able to send mail using domino server. Would like to share few things that I came across -

  1. Using $session->GetEnvironmentString("MailServer",True); figured out the server where session is an instance of COM object for Notes.NotesSession like new COM( "Notes.NotesSession" );

  2. Secondly, I was trying with port 1352 which I got from netstat command for this particluar server process. But it didnt work and finally worked on 25 only.

  3. Domino server was not accepting authentication, so used mail($to,$subject,$message,$headers); instead of $mail = $smtp->send($to, $headers, $body);

Happy that it worked. Thanks all for the help and suggestions.

anujin
  • 745
  • 7
  • 24
  • 36
0

Using your local Notes Client or a Notes Client installed on a "server" via COM to send mail is not a good idea. What you want is to send email from PHP via an SMTP server (which can be a Domino server, as Per pointed out).

Sending email via PHP is for example explained here and here. For the name of the server, the port used for SMTP and optional credentials, please contact your local Domino admin.

Community
  • 1
  • 1
leyrer
  • 1,454
  • 7
  • 9