anujin
anujin

Reputation: 781

How to send email in lotus notes using PHP

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 = "[email protected]";
        $to = "[email protected]";
        $subject = "Test!";
        $body = "Hi,\n\nTest?";

        $host = "d23abcd";
        $port = "1352";
        $username = "[email protected]";
        $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";

Upvotes: 1

Views: 4707

Answers (3)

anujin
anujin

Reputation: 781

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.

Upvotes: 1

leyrer
leyrer

Reputation: 1492

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.

Upvotes: 0

Per Henrik Lausten
Per Henrik Lausten

Reputation: 21709

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).

Upvotes: 3

Related Questions