HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

How to setup EmailDiscussion plugin to use SMTP server at Settings > Outgoing Email

Hi:

the EmailDiscussion plugin is using the default email relay of my hosting provider. How can I setup the plugin to instead use the SMTP server defined at Settings > Outgoing Email?

Thank you!
Bob H.

Comments

  • Fill out the details in the form. You will need to get the details from your SMTP host.

    Search first

    Check out the Documentation! We are always looking for new content and pull requests.

    Click on insightful, awesome, and funny reactions to thank community volunteers for their valuable posts.

  • Hi @hgtonight:

    I know my SMTP settings. I entered the info. in the form at Settings > Outgoing Mail and other system emails are going out through my SMTP server. But the EmailDiscussion plugin is apparently not using it, rather it's sending out through my host's relay. I'm thinking the default.php file for the EmailDiscussion plugin can be modified?

    Thank you!
    Bob H.

  • RiverRiver MVP
    edited July 2016

    @ObamaCare_Forums said:
    Hi @hgtonight:

    I know my SMTP settings. I entered the info. in the form at Settings > Outgoing Mail and other system emails are going out through my SMTP server. But the EmailDiscussion plugin is apparently not using it, rather it's sending out through my host's relay. I'm thinking the default.php file for the EmailDiscussion plugin can be modified?

    Thank you!
    Bob H.

    https://vanillaforums.org/addon/emaildiscussion-plugin

    uses mail()

    maybe this might help

    http://stackoverflow.com/questions/977592/what-smtp-server-does-php-mail-use-by-default-and-are-there-better-options

    or take a look at vanilla code to see how it accomplishes it.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • RiverRiver MVP
    edited July 2016

    @ObamaCare_Forums said:
    Hi @hgtonight:

    I know my SMTP settings. I entered the info. in the form at Settings > Outgoing Mail and other system emails are going out through my SMTP server. But the EmailDiscussion plugin is apparently not using it, rather it's sending out through my host's relay. I'm thinking the default.php file for the EmailDiscussion plugin can be modified?

    Thank you!
    Bob H.

    https://www.sitepoint.com/sending-emails-php-phpmailer/

    since vanilla uses phpmailer to manage mail.
    vanilla would take care smtp connection based on config statements and you need to setup the to, the subject and the body of message and send it.

    so you might change in default.php NOT TESTED but you could test it with one user

    look for

       foreach($Emails as $Email) {
                    mail($Email, $Subject, $Message, $Headers);
                }
    

    replace with

       foreach($Emails as $Email) {
           $MyMailer = new Gdn_Email();
           $MyMailer->to($Email)
           ->subject($Subject))
           ->message($Message)
           ->send();
    }
    

    for a one user test comment out loop and put your own email address in.

       //   foreach($Emails as $Email) {
     $MyMailer = new Gdn_Email();
               $MyMailer->to("your email address here)
               ->subject($Subject))
               ->message($Message)
               ->send();
       //  }
    

    here is an example with rapidmailer. although you would need to roll your own since vanilla doesn't use swift-mailer.
    https://www.sitepoint.com/sending-email-with-swift-mailer/

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • Hi @River

    That worked. Thank you!

    Of course, now I have another issue. I have previously mass deleted many users using the Bulk Edit plugin but I guess the emails still exist in the dB with syntax user_1@deleted.email, user_2@deleted.email, etc.

    I'm afraid if I delete those directly from the table it might break dB integrity. But I do exclude some emails specifically from these sends, i.e. people who have unsubscribed, with statement:

    $ExcludeUsers = array(
    "user1@domain.com",
    "user2@domain.com",
    "etc."
    );

    So, without individually adding each of the deleted emails can I use a 'like' statement to exclude them, perhaps something like:

    $ExcludeUsers = array(
    "user1@domain.com",
    "user2@domain.com",
    where email like %user%@deleted.email
    );

    Or, maybe I can just delete all of those emails directly from the table w/o breaking entity relationships?

    Thanks very much for any insights!

  • Or, maybe I can just delete all of those emails directly from the table w/o breaking entity relationships?

    I don't think River will be back, but I would say that you can likely remove them from the database by deleting the entire user and not just the email… But you can also just delete just emails.

    Execute the query

    DELETE FROM TABLE_NAME WHERE id = SOMEVALUE <<<in this case the value would be "deleted" or the entire email address...

    DELETE FROM WHERE id = deleted

    But this kind of info is best gotten from tutorials which tell you how to do an sql query.

    http://www.w3schools.com/sql/sql_delete.asp

    http://www.tutorialspoint.com/sql/sql-drop-table.htm

    http://www.sqlcourse.com/delete.html

    http://dev.mysql.com/doc/refman/5.7/en/delete.html

  • RiverRiver MVP
    edited July 2016

    For those people who stumble in here, read the above with lots of CAVEATS or you might run into issues.

    Be very, very, very careful if you delete the Deleted Users from the User Table. Under some circumstances it might be ok. BUT it is not advisable unless you understand the linkages between tables. If you delete a deleted user row form the user table and you still have other tables activity, conversations, discussions, comments, yaga, other plugins and there is still an entry in those tables for that userid, you may run into BIGGER problems. If you use no other plugins that have ids in them and you deleted with the option with delete ALL CONTENT, you might be ok, but if you are not feeling "REALLY LUCKY" and don't have clue about the database linkages, I would advise you to NOT to mess with the TABLES.

    If you deleted a user and said blank content or a partial delete, YOU DEFINITELY DO NOT want to DELETE table entries, unless you feel confident you can clean up all the linkages in all the other tables.

    @ObamaCare_Forums said:
    Hi @River

    That worked. Thank you!

    Of course, now I have another issue. I have previously mass deleted many users using the Bulk Edit plugin but I guess the emails still exist in the dB with syntax user_1@deleted.email, user_2@deleted.email, etc.

    I'm afraid if I delete those directly from the table it might break dB integrity. But I do exclude some emails specifically from these sends, i.e. people who have unsubscribed, with statement:

    If you deleted a user and said blank content or a partial delete, YOU DEFINITELY DO NOT want to DELETE table entries, unless you feel confident you can clean up all the linkages in all the other tables.

    $ExcludeUsers = array(
    "user1@domain.com",
    "user2@domain.com",
    "etc."
    );

    So, without individually adding each of the deleted emails can I use a 'like' statement to exclude them, perhaps something like:

    $ExcludeUsers = array(
    "user1@domain.com",
    "user2@domain.com",
    where email like %user%@deleted.email
    );

    you are mixing and matching SQL type commands with something that occurs in the ARRAY.

    so you have a few choices change the SQL commands.

    the SQL way

    change this

        ->From('User')
             ->Get();
    

    to this

        ->From('User')
            ->Where("Deleted",0)
             ->Get();
    

    since deleted users have a 1 in the deleted column in the user table, you only want to look for users that have a 0, which the above where command uses. You could use a where and like on the email field, but the above might be preferable over a like.

    the for-loop way

    ... (but the SQL way above might be better).
    you could also change it a different way, in the for each loop with a continue and a preg_match

    adding the match and continue causes the rest of the loop to be skipped and prevents the email from being sent.

    foreach($Emails as $Email) {
                 if (preg_match("/.*deleted.email/",$Email)) continue;
    

    Or, maybe I can just delete all of those emails directly from the table w/o breaking entity relationships?

    maybe, maybe not, all depends what you did and what you know, see first paragraph. How LUCKY do you feel?
    the SQL change or the for each loop change is safer.

    http://php.net/manual/en/function.preg-match.php

    http://php.net/manual/en/control-structures.continue.php

    Thanks very much for any insights!

    multiple insights and provisos and caveats explained.

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • Hi @vrijvlinder :

    I ended up deleting the users from the table. Since email column cannot be null and I didn't want to change the table structure, my update statement setting email to NULL instead defaulted to empty, after which the send email operation kicked out an error indicating at least one email must be present.

    Thank you,
    Bob H.

  • some new documentation if you want to spruce things up.

    http://docs.vanillaforums.com/developer/framework/email/

    Pragmatism is all I have to offer. Avoiding the sidelines and providing centerline pro-tips.

  • I have no indexed this discussion becuase of the context spammer. Once the spam content is removed then the no-index can be removed.

    grep is your friend.

  • Spammer removed. Can't see how to remove No Index...

Sign In or Register to comment.