Advertisement:

Author Topic: Way to monitor attempt to send email?  (Read 1144 times)

Offline Josh @ Dreamland

  • Semi-Newbie
  • *
  • Posts: 13
Way to monitor attempt to send email?
« on: October 18, 2017, 12:41:33 AM »
Hi all,

I'm trying to configure my board to send mail through Gmail. I've done a lot of digging, and found that the correct configuration should be as follows:

SMTP server:ssl://smtp.gmail.com
SMTP port:465
SMTP username:full-email@gmail.com
SMTP password:gmail-password

Unfortunately, this isn't working. More digging suggested that the problem was that the PHP OpenSSL module wasn't being loaded, but this is not the case ("openssl" appears in the output of `php --modules`).
I checked basically everything under /var/logs... nothing relevant is being written there. Nothing in maillog nor tt]error_log[/tt].

I tried different schemes under "server." In addition to `ssl://,` I have tried tls, tlsv1.0, tlsv1.1, and tlsv1.2. The lattermost actually generated a useful error:

Code: [Select]
[Wed Oct 18 00:10:24.985993 2017] [:error] [pid 13137] [client 98.239.128.47:48240] PHP Warning:  fsockopen(): unable to connect to tlsv1.2://smtp.gmail.com:465 (Unable to find the socket transport "tlsv1.2" - did you forget to enable it when you configured PHP?) in /var/www/html/enigma-dev.org/forums/Sources/Subs-Post.php on line 1332

But other than that, I have no indication of what might be going wrong. The messages are not removed from the queue as they are sent; instead, their timestamp is reset to the epoch. There is nothing in my forum's own error log about this, either.

Is there a way to try to send these emails from my command line? All I get when I attempt to do that is the string, "Hacking attempt." I imagine some error must be generated during this process, because otherwise, how does SMF know not to remove the email from the queue? Every time I look for how I might test sending mail in SMF, all I get is some telnet commands or a `mail` command. That doesn't test SMF's configuration... only my MTA.

Any help tracking this down would be greatly appreciated. Otherwise, I think I may have to configure my own MTA as a relay to Gmail.

Thanks in advance!

Online vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 21,557
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Way to monitor attempt to send email?
« Reply #1 on: October 18, 2017, 12:59:24 AM »
If you do a phpinfo page check under "Registered Stream Socket Transports"
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline Josh @ Dreamland

  • Semi-Newbie
  • *
  • Posts: 13
Re: Way to monitor attempt to send email?
« Reply #2 on: October 18, 2017, 01:14:41 AM »
Thanks for the quick reply! I get these:

Code: [Select]
tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
I went ahead and tested with sslv2/v3; same result as plain ssl.
­
« Last Edit: October 18, 2017, 01:27:58 AM by Josh @ Dreamland »

Offline aegersz

  • SMF Hero
  • ******
  • Posts: 1,494
  • Gender: Male
  • "mods" junkie
    • dopetalk
Re: Way to monitor attempt to send email?
« Reply #3 on: October 21, 2017, 03:35:24 PM »
hey, try this is (as a fix to your problem) as it worked for me ...

https://www.simplemachines.org/community/index.php?topic=544856.msg3870010#msg3870010
The configuration of my Linux VPS (SMF 2.0 with 145 mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum)

Offline Josh @ Dreamland

  • Semi-Newbie
  • *
  • Posts: 13
Re: Way to monitor attempt to send email?
« Reply #4 on: October 21, 2017, 04:15:12 PM »
Well, I'll be. That indeed fixed it. I wonder why such a patch hasn't already been made, since that line seems to just check for support of EHLO... Anyway, thank you very much! Awesome to have email working. Once I edited that line, I got an email from Google letting me know some weird server was trying to use my account. I allowed access to "Less secure apps," and suddenly, everything worked perfectly.

Thanks again!

Offline aegersz

  • SMF Hero
  • ******
  • Posts: 1,494
  • Gender: Male
  • "mods" junkie
    • dopetalk
Re: Way to monitor attempt to send email?
« Reply #5 on: October 26, 2017, 06:55:54 AM »
mainly for educational purposes, i turned this tiny code change into a mod for my 2.0.14 system ... it works but it is obviously not sanctioned by Simple Machines ... BUT it does demonstrate how to build/package the most basic components of a mod (for any aspiring mod authors wondering where to start). Unlike me, i suggest that one learns php !

package-info.xml:

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE package-info SYSTEM "http://www.simplemachines.org/xml/package-info">

<package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
        <id>aegersz:smtpssl</id>
        <name>SMTP-SSL</name>
        <version>1.0</version>
        <type>modification</type>
        <install>
                <modification format="xml" type="file">install.xml</modification>
        </install>
        <uninstall>
                <modification reverse="true">install.xml</modification>
        </uninstall>
</package-info>

install.xml:

Code: [Select]
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">

<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
        <id>aegersz:smtpssl</id>
        <version>1.0</version>
        <file name="$sourcedir/Subs-Post.php">
                <operation>
                        <search position="replace"><![CDATA[
                // EHLO could be understood to mean encrypted hello...
                if (server_parse('EHLO ' . $modSettings['smtp_host'], $socket, null) == '250')
]]></search>
                        <add><![CDATA[
                // EHLO could be understood to mean encrypted hello...
//              if (server_parse('EHLO ' . $modSettings['smtp_host'], $socket, null) == '250')
                if (server_parse('EHLO ' . 'localhost', $socket, null) == '250')
]]></add>
                </operation>
        </file>
</modification>
The configuration of my Linux VPS (SMF 2.0 with 145 mods & some assorted manual tweaks) can be found here and notes on my mods can be found here (warning: those links will take you to a drug related forum)