Skip to:
Content
Pages
Categories
Search
Top
Bottom

phpmailer, swiftmailer, smtp authentication, registration email sending problems


  • chrissydunno
    Member

    @chrissydunno

    has anyone seen a complete solution for this issue? many hosts do not allow php mail() function because it doesn’t support smtp authentication

    i’ve seen several posts about swiftmailer, phpmailer alternatives, but none offer a step by step instructions?

    interested in modifying files only from the latest verion bbpress-0.9.0.2.zip

    also, are any of these solutions integrated with wordpress? or when you use them you lose the bbpress user = wp user integration?

    any kind of complete solution would be appreciated by many

Viewing 13 replies - 1 through 13 (of 13 total)

  • chrishajer
    Participant

    @chrishajer

    I don’t know about a complete solution, but I’ve been able to get this one working.

    Email Authentication Issue

    If it becomes a large enough issue, I imagine someone will create a plugin for it. Until then, this is a work around.

    Integrating something like this does not affect WordPress integration as far as I know. It’s just the email function. I imagine WordPress would have the same issue sending out emails unless you use a plugin like this there as well.


    _ck_
    Participant

    @_ck_

    It really is that simple – just make HowToGeek’s code into a plugin and install swiftmailer:

    https://bbpress.org/forums/topic/trick-to-fix-some-email-problems-with-08x-plugins-on-09x#post-15776

    That reminds me to fix some of my plugins so they use bb_mail() instead of mail() directly.


    chrissydunno
    Member

    @chrissydunno

    thanks guys .. but how do you ‘make howtogeek’s code into a plugin’

    where does his code go? registration-settings.php? how?

    i can install swiftmailer of course, just not sure what else needs to change in current bbpress configurations


    chrishajer
    Participant

    @chrishajer

    You take all that code that howtogeek pasted and put it into a file called “replacebbmail.php” or something. To make php code into a bbPress plugin, it needs to have a header. The header needs to look something like this (change the values to something meaningful to you):

    <?php
    /*
    Plugin Name: Swift Mailer
    Plugin URI: http://www.example.com/ (doesn't really matter)
    Description: Replace bb_mail with Swift Mailer
    Author: You
    Author URI: http://www.example.com/
    Version: 0.1
    */

     

    Then, paste the code that howtogeek showed at the end of that file. In the end, it will look something like this.

    <?php
    /*
    Plugin Name: Swift Mailer
    Plugin URI: http://www.example.com/ (doesn't really matter)
    Description: Replace bb_mail with Swift Mailer
    Author: You
    Author URI: http://www.example.com/
    Version: 0.1
    */

    if ( !function_exists('bb_mail') ) {
    function bb_mail($to, $subject, $content, $headers=''){

    require_once('PATH_TO/Swift/lib/Swift.php');
    require_once('PATH_TO/Swift/lib/Swift/Connection/Sendmail.php');

    $swift =& new Swift(new Swift_Connection_Sendmail("/usr/sbin/sendmail -bs"));
    $from = new Swift_Address("noreply@mysite.com","My bbPress Forums");

    $message =& new Swift_Message($subject, $content);
    if ($swift->send($message, $to, $from)) {return true;}
    else{ echo "Message failed to send to ".$to." from ".$from;}
    $swift->disconnect();
    }
    }
    ?>

     

    The name of the file does not matter really. Save that new file in bb-plugins. Now activate your new plugin in the admin section of your bbPress site.

    You will need to configure it before activating it to make sure it works (setting up the path to swift mailer and setting the auth stuff if you need to.)


    chrissydunno
    Member

    @chrissydunno

    you guys rock

    just changed from sendmail to smtp, added authentication, made path changes and it works!

    here is the template for my plugin

    <?php

    /*

    Plugin Name: Swift Mailer

    Description: Replace bb_mail with Swift Mailer

    Version: 0.1

    */

    if ( !function_exists(‘bb_mail’) ) {

    function bb_mail($to, $subject, $content, $headers=”){

    require_once(‘MYSWIFTFOLDER/lib/Swift.php’);

    require_once(‘MYSWIFTFOLDER/lib/Swift/Connection/SMTP.php’);

    $smtp =& new Swift_Connection_SMTP(“MYSMTPSERVER”, 25);

    $smtp->setUsername(“MYEMAILLOGIN”);

    $smtp->setpassword(“MYEMAILPASSWORD”);

    $swift =& new Swift($smtp);

    $from = new Swift_Address(“MYFROMEMAIL”,”MYFRIENDLYFROM”);

    $message =& new Swift_Message($subject, $content);

    if ($swift->send($message, $to, $from)) {return true;}

    else{ echo “Message failed to send to “.$to.” from “.$from;}

    $swift->disconnect();

    }

    }

    ?>


    chrishajer
    Participant

    @chrishajer

    Very nice. Glad you got it working.


    Sam Bauers
    Participant

    @sambauers

    We have debated adding the wp-mail class to bbPress to get this functionality built in, but we balked at the sheer size of the code. What is a good lightweight replacement for php-mailer that we can consider adding to backpress?

    I can’t seem to get this to work. I followed the instructions and put in the paths to my SwiftMailer directory, but the plugin just errors out when I try to activate it.

    I really would like to get this sorted out, new users are registering on my forums, and many are not getting registration emails…


    chrishajer
    Participant

    @chrishajer

    What sort of error are you seeing? It’s hard to help resolve an issue as vague as “just errors out.” The error messages might be important. Please offer more detail.


    singlezhang
    Member

    @singlezhang

    I can get it work, with this plugin new users can receive the reg-email. But the problem is the users can not login. After click login button a blank page come out. If deactive the plugin, the users can login, but new users can not receive the reg-email.

    with IIS+PHP5, wordpress 2.5.1,


    chrishajer
    Participant

    @chrishajer

    singlezhan: Please start a new thread. Sounds like you have something else going on.


    Sam Bauers
    Participant

    @sambauers

    1.0-alpha now includes php-mailer from WordPress.

    I’ve added a plugin for 1.0-alpha to allow sending of email via an SMTP server. https://bbpress.org/plugins/topic/smtp-mailer-for-bbpress/


    Sam Bauers
    Participant

    @sambauers

    Actually it will be in 1.0-alpha-2 (the next alpha release)

Viewing 13 replies - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.
Skip to toolbar