How to send email in lotus notes using PHP

a 夏天 提交于 2019-12-08 03:11:41

问题


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";

回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/10766693/how-to-send-email-in-lotus-notes-using-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!