Specifying SMTP server

Discussion in 'General Support' started by cavimales, Jun 19, 2009.

  1. cavimales

    cavimales New Member

    Joined:
    Mar 19, 2009
    Messages:
    12
    Likes Received:
    0
    Hi!

    Is there a way in webid to specify the SMTP server other than in php.ini? I don't have privileges to modify php.ini in the server I've deployed webid. Is there anyway around?
     
  2. renlok

    renlok Administrator Staff Member

    Joined:
    Oct 20, 2008
    Messages:
    2,858
    Likes Received:
    330
    urm if your server allows it you could probably do it with ini_set

    so add
    PHP:
    ini_set('SMTP''your_SMTP_server');
    somewhere in the config.inc.php file
     
  3. cavimales

    cavimales New Member

    Joined:
    Mar 19, 2009
    Messages:
    12
    Likes Received:
    0
    Thanks renlok for your prompt reply!

    The function ini_set() returns true, but no mails are sent. I could not figure out what might be wrong. :(

    I came across phpMailer - a php mailing script that can be used to specify SMTP server. With that script I could send mails by specifying the SMTP server!

    what may be the problem? Why I can't specify the SMTP server using ini_set()?
     
  4. renlok

    renlok Administrator Staff Member

    Joined:
    Oct 20, 2008
    Messages:
    2,858
    Likes Received:
    330
    idk i think the SMTP value is only used on windows servers, i guess your probably running linux?

    i found this function you could try this.
    in includes/functions_email.php find
    PHP:
    }
    ?>
    and before it add
    PHP:
    function SMTPmail($Recipient$Subject$Message$headers '')
    {
        
    $Sender 'YOUR_EMAIL';
        
    $Server 'YOUR_SMTP_SERVER';
        
    $Sock fsockopen($Server25);
        
        if (
    is_resource($Sock))
        {
                echo 
    fread($Sock1024);flush();
            
    fwrite($Sock"HELO localhost\r\n");
                echo 
    fread($Sock1024);flush();
            
    fwrite($Sock"MAIL FROM: <$Sender>\r\n");
                echo 
    fread($Sock1024);flush();
            
    fwrite($Sock"RCPT TO: <$Recipient>\r\n");
                echo 
    fread($Sock1024);flush();
            
    fwrite($Sock"DATA\r\n");
                echo 
    fread($Sock1024);flush();
            
    fwrite($Sock"From: <$Sender>\r\n");
            
    fwrite($Sock"To: <$Recipient>\r\n");
            
    fwrite($Sock"Subject: $Subject\r\n");
            
    fwrite($Sock"\r\n");
            
    fwrite($Sock"$Message\r\n");
            
    fwrite($Sock".\r\n");
                echo 
    fread($Sock1024);flush();
            
    fwrite($Sock"QUIT\r\n");
                echo 
    fread($Sock1024);flush();
                
            
    fclose($Sock);
     
            return 
    true;
        }
     
        return 
    false;
    }
    then in the same file change both instances of the mail function to be $this->SMTPmail( instead of mail(
     
  5. cavimales

    cavimales New Member

    Joined:
    Mar 19, 2009
    Messages:
    12
    Likes Received:
    0
    Thanks Renlok! It works :) (Sorry for the delay in posting the reply)

    One suggestion: can you make all the mail functions to be handled by the class email_class? This will make any modifications to mail related function easier. In the system some mails are sent using php mail() function and some mails are sent using the email_class' functions.
     
  6. renlok

    renlok Administrator Staff Member

    Joined:
    Oct 20, 2008
    Messages:
    2,858
    Likes Received:
    330
    yeah i will im going to add an option to choose to use mail() or an SMTP server as quite a few people have asked me to do this.
     
  7. ericdeaver

    ericdeaver New Member

    Joined:
    Aug 17, 2009
    Messages:
    3
    Likes Received:
    0
    SMTP Update?

    Any updates on the SMTP implementation?? I would really love to use this script, but I don't seem to be able to setup a SMTP override with the code below-- I will continue to work on finding a solution, but would be awesome if we could select this option @ time of install.

    Thanks!
    /cheers
     
  8. stuffdone

    stuffdone New Member

    Joined:
    Dec 18, 2009
    Messages:
    1
    Likes Received:
    0
    I tried this. Entire site crashed and I get nothing but blank pages now. Even restoring the original file did not fix this issue.
     
  9. jmorris1161

    jmorris1161 New Member

    Joined:
    Nov 19, 2008
    Messages:
    73
    Likes Received:
    0
    I got the code to work BUT

    It posts all the html code with it i.e. <table> <br> etc. I cannot for the life of me figure out how to make it right or just get it to send plain text that would even work.

    Also you have to put it right before the final
    ?>
    not before the
    }
    ?>
    Or you will get a site crash all white screens.
     
  10. bigdog

    bigdog New Member

    Joined:
    Dec 21, 2009
    Messages:
    71
    Likes Received:
    0
    Username and password variables would be required for some as well
    renlok checkout PHPMailer class this will add a mere 90kb and provide
    a way to use gmail or whatever SMTP server you want. I use it for almost
    every script now, you can do anything with that, then you can do with
    default mail function and more.
     
  11. rnll

    rnll New Member

    Joined:
    Jan 30, 2011
    Messages:
    1
    Likes Received:
    0
    I did the above but not sure if I did this correctly. I saw your note but can't see the rest of it as it is cut off on the screen.

    function sendmail()
    {
    if (is_array($this->to))
    {
    for ($i = 0; $i < count($this->to); $i++)
    {
    mail($this->SMTPmail, $this->subject, $this->message, $this->headers);
    }
    }
    else
    {
    mail($this->SMTPmail, $this->subject, $this->message, $this->headers);
    }
    }
     
  12. sprokkel

    sprokkel Active Member

    Joined:
    Apr 1, 2013
    Messages:
    162
    Likes Received:
    7
    I cant find functions_email.php in the maps of Webid,
    I have the same problem whit mail that not sending to new users
    Who can help me whit this, i have a paid server
    I have call them and the say i need a SMTP script
     
  13. nay27uk

    nay27uk Super Moderator Staff Member

    Joined:
    Nov 24, 2009
    Messages:
    5,573
    Likes Received:
    550
    forum search there are a few examples on this forum I have even pointed you to them before in one of your other threads
     
  14. sprokkel

    sprokkel Active Member

    Joined:
    Apr 1, 2013
    Messages:
    162
    Likes Received:
    7
    Nay, please help me to find to good topic i need,
     
  15. sprokkel

    sprokkel Active Member

    Joined:
    Apr 1, 2013
    Messages:
    162
    Likes Received:
    7
    Thanks
    Its already fixed
     
  16. hopefulAuctioneer

    hopefulAuctioneer New Member

    Joined:
    Apr 15, 2021
    Messages:
    3
    Likes Received:
    0
    Hello everyone!
     
  17. hopefulAuctioneer

    hopefulAuctioneer New Member

    Joined:
    Apr 15, 2021
    Messages:
    3
    Likes Received:
    0
    Did this get fixed yet?
     
  18. hopefulAuctioneer

    hopefulAuctioneer New Member

    Joined:
    Apr 15, 2021
    Messages:
    3
    Likes Received:
    0
    Thank you for any info. Also, is anyone working on updates for the We Bid program?
     

Share This Page