ℹ️
Welcome to the archive of the old FlatPress support forum. Browse more than a decade of FlatPress wisdom! Login is disabled.

The current FlatPress support forum is available here: forum.flatpress.org
Sending notifications with Gmail SMTP redux
  • Zell_ff8 in http://flatpress.org/vanilla2/discussion/comment/4980 provided a core hack to use PHPMailer to send email using Gmail's SMTP servers. I had some trouble setting this up on my FP instance but finally got it to work. I took his/her code and rewrote it with enough comments to help someone who (like me) has never used PHPMailer before. I posted the code to pastebin.com at http://pastebin.com/1PWNuZMV because it's sorta long and the syntax highlighting really helps.

    I also decided to try to get PEAR Mail to work with FP and Gmail as well since I successfully hacked another CMS to use it. That effort is also at pastebin.com: http://pastebin.com/DMbKrHA5

    Note that Gmail seems to sometimes have a security fit if the SMTP login and recipient are the same. In other words, you might find Gmail more compliant if the SMTP login is different from the blog's email.

    Finally, I am (obviously?) not a PHP coder. This means two things:
    1. If you run unto trouble, I will only be able to offer limited help.
    2. I am sure there are things that could be improved in both of the above--some of which are marked as TODOs. Any suggestions would be very welcomed.
    Finally (no, really this time) since PHPMailer is GPL, why doesn't FP use it by default. If that's an insane idea, what about a plugin?

    Cheers,
    -M

  • Hi, nice work.

    I'll try to answer to you final questions.
    I think that Flatpress hasn't included PhpMailer because the mail feature wasn't important at the time that NoWhereMan added it (it's just a guess, wait until he replies) and the mail function works in most cases.

    For the second question: to make a plugin that sends emails, a hook is required, so the Flatpress code should be modified (just a line).
    Maybe NoWhereMan will do it, however you will have to wait until the next version of flatpress is released (or use an "unstable" one from subversion).
  • pierovdfn is right about utils_mail() not being a priority, since it does work most of the time. for what concerns the plugin extension, patches are welcome. I guess utils_mail() body should be moved to an action, and then a plugin could remove that action and register its own.

    pseudo code:

    function utils_mail(…) {
       do_action('fp-mail', $arguments);
    }

    function actual_utils_mail($arguments) {
      // do what utils_mail() did once
    }

    in core.wp-default-filters.php add add_action('fp-mail', 'actual_utils_mail');

    a plugin then may:
    remove_action('fp-mail', 'actual_utils_mail');
    add_action('fp-mail', 'my_new_mail_send_function');

  • Well, it should have as first parameter if the mail was sent, otherwise the mail will be sent as many times as the number of plugins that one has enabled.
    Normally one has just a plugin enabled but it's just to be precise ;-)
Start a New Discussion

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion