News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Anybody having recent issues with gmail?

Started by Dwev, January 03, 2018, 10:25:06 AM

Previous topic - Next topic

Dwev

I just can't get my G-Suite account to work with SMF.

I did both the edits to Sources/Subs-Posts.php and entered ssl://smtp.gmail.com with port 465 and the right mail address and password.
On top of hat I went into my G-Suite account en enabled to use less secure apps, but still no dice.
I'm testing this by going to members waiting for activation and sending reminders to an account I own.

Is there anyone that can help?
I really need this to work, the forum is going live soon and I definitely want to be using the Gmail-servers at that moment.

Shambles

Anything mail-related in your forum error log?

Dwev

Nothing that I can see (though the forum seems to generate a awful lot of errors, but that's for another thread, I guess).

Is the way I'm testing if the mail is working the right way?
(going to a specific member waiting for activation, and sending reminders)

Aleksi "Lex" Kilpinen

How about trying to send a newsletter to yourself? To the same address you are trying to use as the sender. That would at least tell you if you are able to get it to reach gmail in the first place.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

SaltedWeb

My own personal experiences with SMF, is   Gmail doens't play well with forums. And that Godaddy hosting doesn't play well with SMF.
Not that they are related but seems on the topics of errors people tend to have more problems with Gmail and Godaddy as causes for their problem.  I see you really want to use Gmail, but I can say using it in the past I had some very crucial emails going thru SMF that did not reach the people it should and it ended up costing me allot of money. I personally do not find it reliable to use of a forum because of its known spotty service this is not just SMF I had same issues with paid forum software like Xenforo.  Just throwing it out there as a side note to think about.
Knowing your limitations makes you human, exceeding these limitations makes you worthy of being human.

Aleksi "Lex" Kilpinen

Quote from: SaltedWeb on January 04, 2018, 01:15:41 PM
I personally do not find it reliable to use of a forum because of its known spotty service this is not just SMF I had same issues with paid forum software like Xenforo.  Just throwing it out there as a side note to think about.
It's not about the script sending the mails, it's about the server handling them really.
And a lot of other variables, like domains and receiving mail services, and spam filters and so on...
Forums can send out mail perfectly to large audiences, if everything works.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Dwev

Quote from: Aleksi "Lex" Kilpinen on January 04, 2018, 09:07:08 AM
How about trying to send a newsletter to yourself? To the same address you are trying to use as the sender. That would at least tell you if you are able to get it to reach gmail in the first place.

Tried this, no dice.
So I went back to the mail-options I had earlier (not Google, from the provider) and newsletters still don't get sent (I get a Gateway Timeout).

I'm trying to find if there are errors in the logs that point to the problem, but how do I recognise errors that are related to problems with the mail-function?

Aleksi "Lex" Kilpinen

Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Dwev

@ Aleksi: didn't know about this script, thanks for pointing me to it!

Just tried it and it worked on both sides!!
So I guess this means that the mail is working, but the Newsletter isn't.

I'll test the same script with the settings for Gmail, would be nice if that would work as well
(though I understand Gmail and SMF often don't really 'like' each other much).

Aleksi "Lex" Kilpinen

That tells us that your server can send mail, and the PHP option should work at least.
Then the next step would be to try and find out why the SMTP options you are using do not work.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Dwev

Quote from: Aleksi "Lex" Kilpinen on January 05, 2018, 08:23:59 AM
That tells us that your server can send mail, and the PHP option should work at least.

So some good news, but not good news all around, yes?

Quote
Then the next step would be to try and find out why the SMTP options you are using do not work.

Do you know how I can test this?

By the way, I just changed the settings to Gmail and again, success on both sides! :D

Aleksi "Lex" Kilpinen

No good ideas from me really, apart from what you yourself already mentioned - it should probably leave something in your logs when failing. I have never really tried to get gmail to work, as I have always found it easier to just create a local domain address and use the PHP mail functionality.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Jailer

I gave up on gmail a while ago and went with mailgun. Haven't had any issues since.

Dwev

Still trying to understand this, which leads me to the following question:

if the PHP-test worked with Gmail, can't I just choose PHP-mail instead of SMTP-mail in the Email-setting?

Aleksi "Lex" Kilpinen

You could, but that could end up causing more trouble since, as I understand it, you would be effectively forging the sender address. When you use that option, it is not actually sent through gmail.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Dwev

Quote from: Aleksi "Lex" Kilpinen on January 05, 2018, 06:13:56 PMWhen you use that option, it is not actually sent through gmail.

Hmm, so definitely not an option, not looking for forging anything of course.

Guess making sure that the SMTP option works is the only valid option...

Illori

if you use the php mail option to SEND to a gmail address using an email address that is on your domain there is no issue. if you want to SEND from a gmail address then you need to set up smtp.

Dwev

Quote from: Illori on January 05, 2018, 06:22:43 PMif you want to SEND from a gmail address then you need to set up smtp.

That's the option that I want to get to work.

Would be great if there was an easy option to check if it works (like with the PHP-script).

tinoest

I think you need to apply the changes I made to SMF2.1 for Gmail to work.

So go to Subs-Post.php and add this to the start of the smtp_mail function.



if (function_exists('gethostname') && gethostname() !== false)
$helo = gethostname();
elseif (function_exists('php_uname'))
$helo = php_uname('n');
elseif (array_key_exists('SERVER_NAME',$_SERVER) && !empty($_SERVER['SERVER_NAME']))
$helo = $_SERVER['SERVER_NAME'];

if (empty($helo))
$helo = $modSettings['smtp_host'];


Then find this

if (server_parse('EHLO ' . $modSettings['smtp_host'], $socket, null) == '250')

And replace with

if (server_parse('EHLO ' . $helo, $socket, null) == '250')

You might also need to add this after the above if statement.


// Send STARTTLS to enable encryption
if (!server_parse('STARTTLS', $socket, '220'))
return false;
// Enable the encryption
if (!@stream_socket_enable_crypto($socket, true, STREAM_CRYPTO_METHOD_TLS_CLIENT))
return false;
// Send the EHLO command again
if (!server_parse('EHLO ' . $helo, $socket, null) == '250')
return false;





Aleksi "Lex" Kilpinen

Quote from: tinoest on January 07, 2018, 12:55:14 PM
I think you need to apply the changes I made to SMF2.1 for Gmail to work.
Thank's - This I guess is due to Gmail being picky about the connections then :)
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Dwev

Quote from: tinoest on January 07, 2018, 12:55:14 PMSo go to Subs-Post.php and add this to the start of the smtp_mail function.

Before I start with this I want to be 100 percent sure.

The first bit of code should be added "to the start of the smtp_mail function", does this mean it should be added right after this?

// Send an email via SMTP.

aegersz

Sorry to butt in but this may help ... I manged to get this working after a code change ... see https://www.simplemachines.org/community/index.php?topic=556674

spooky ... the fix mentioned in there takes you back to April 03, 2016 to a thread called "Anybody having recent issues with gmail?"
The configuration of my Linux VPS (SMF 2.0 with 160+ 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). My (House) music DJ dedication page is here

tinoest

Quote from: Dwev on January 08, 2018, 05:42:58 AM
Quote from: tinoest on January 07, 2018, 12:55:14 PMSo go to Subs-Post.php and add this to the start of the smtp_mail function.

Before I start with this I want to be 100 percent sure.

The first bit of code should be added "to the start of the smtp_mail function", does this mean it should be added right after this?

// Send an email via SMTP.


No after the function bit. If you want to post your subs-post.php file. I'll manually edit it then upload it again.

tinoest

The attached modification should also work, I've not tested it but it looks ok.

Dwev

@ aegersz: I did read probably all of the posts about Gmail on this forum, maybe I subconsciously copied that subject (definitely not on purpose!  ;)).

@ tiniest: the zip you posted was almost empty, so that didn't work (error starts with "Although the package was downloaded to the server it appears to be empty.").

But I'm adding my Subs-Post.php, if you can edit that one so that Gmail's SSL SMTP would work I would be much obliged!

tinoest

Quote from: Dwev on January 08, 2018, 05:25:55 PM

@ tinoest: the zip you posted was almost empty, so that didn't work (error starts with "Although the package was downloaded to the server it appears to be empty.").

It should contain two files, or atleast it does when I download it.

I'll look at the code tomorrow, most likely won't get round to changing it until later in the evening.

Ignore that, see the attached.

Arantor

Depending on the tool used to make the zip file, SMF can barf on it thinking it is empty (when it clearly isn't)

Dwev

There are indeed two files in it (install.xml and package-info.xml), but I think Arantor is right here, the Package Manager doesn't like the way it's made.

@ tiniest: I'll be patiently waiting for what comes my way, very happy already with all the help I'm getting! 

tinoest

Quote from: Dwev on January 08, 2018, 05:46:44 PM
There are indeed two files in it (install.xml and package-info.xml), but I think Arantor is right here, the Package Manager doesn't like the way it's made.

@ tiniest: I'll be patiently waiting for what comes my way, very happy already with all the help I'm getting!

Its tinoest or tino.

I just uploaded a copy which I think should work.

@arantor

It's probably as I did it on my mac, I seem to recall SMF not liking it when I used that due to the hidden files macOS add's.

Dwev

Quote from: tinoest on January 08, 2018, 05:49:29 PM
Its tinoest or tino.

Sorry about that, I copied your forumname, but autocorrect changed it (good feature in general, with these kind of things really annoying).

Quote
I just uploaded a copy which I think should work.

I'll try it first thing tomorrow!

Dwev

The short answer: it works!!!

The longer answer: after uploading the Subs-Post.php of tinoest is still didn't work.

So I went back to basics and first entered the non-SSL servers of my ISP: working fine.
Next the SSL-servers, everything working as well.
After that Gmail: still nothing.

So I logged onto the Gmail account and under "Apps with account access" I set the option "Allow less secure apps" to ON.
And lo and behold, it's working!!!

I have no clue if it would work without the edited file of tinoest, I hope you forgive me that I really don't want to try...   ;)

Advertisement: