Jump to content

[MOD] TLS Email support - works with gmail smtp!


adamscybot

Recommended Posts

i think this mod should be updated for v4, i can the files above to replace the v4 one and it works fine, but i'm not sure about it as the file have a size different about 5kb between the above files and the v4 one :)

 

Hi. WHMCS 4 uses new phpmailer classes, it is much easier to enable TLS now.

 

Open class.phpmailer.php find "var $SMTPSecure" and set it to "tls"

 

Now put in your smtp server in settings (tls:// is not requires and ssl doesnt need to be ticked). Your done!

 

EDIT: It appears they copied the code I originally posted and put it straight in the v4 release - escept it now doesnt accept tls:// you must change the $SMTPSecure variable directly.

Edited by adamscybot
Link to comment
Share on other sites

Hi. WHMCS 4 uses new phpmailer classes, it is much easier to enable TLS now.

 

Open class.phpmailer.php find "var $SMTPSecure" and set it to "tls"

 

Now put in your smtp server in settings (tls:// is not requires and ssl doesnt need to be ticked). Your done!

 

EDIT: It appears they copied the code I originally posted and put it straight in the v4 release - escept it now doesnt accept tls:// you must change the $SMTPSecure variable directly.

 

Thank you

 

Anthony

Link to comment
Share on other sites

Has anyone had any luck on 4.0? I have followed the directions above by changing var $SMTPSecure" to "tls" and not typing in tls:// and not ticking SSL but I cannot get my mail to go through google apps. I also tried on 3.8.1 with no luck. Does anyone have any advice?

 

Thanks,

 

kmkarim

Link to comment
Share on other sites

ok got it working port 587 is not working for some reason switched to 465 works flawlessly :)

 

I am having the same problem sending with SMTP instead of PHP Mail(). I am using the mailserver of my Dedi Box but i keep getting:

 

Email Sending Failed - SMTP Error: Could not connect to SMTP host.

 

My outgoing port is set to 25 because that is the default of my server. Do I need to change that port number?

Link to comment
Share on other sites

I am having the same problem sending with SMTP instead of PHP Mail(). I am using the mailserver of my Dedi Box but i keep getting:

 

Email Sending Failed - SMTP Error: Could not connect to SMTP host.

 

My outgoing port is set to 25 because that is the default of my server. Do I need to change that port number?

 

Does your SMTP server support TLS?

 

This thread is for those wanting to enable TLS encryption.

Link to comment
Share on other sites

Does your SMTP server support TLS?

 

This thread is for those wanting to enable TLS encryption.

 

Yes, my mailserver supports TLS. I send emails with Microsoft outlook using TLS with no problems. But am not able to do so using WHMCS.

 

Any Solution?

Link to comment
Share on other sites

For anyone still having trouble, here are the settings I am using for Google Apps and WHMCS v4 for sending email.

 

Under General Settings -> Mail:

  • Mail Type: SMTP
  • SMTP Port: 587
  • SMTP Host: smtp.gmail.com
  • SMTP Username: myemail@mydomain.com (this is for me a full user account in google apps, not just an alias or nickname)
  • SMTP Password: <password for the account>
  • SMTP SSL: Left it unchecked.

 

The rest of the settings on the Mail page are self-explanatory and will be whatever you need them set to.

 

Also, I did change the file /path/to/whmcs/includes/class.phpmailer.php and where you see the line:

var $SMTPSecure = "";

replace it with:

var $SMTPSecure = "tls";

 

That is it, for me this setup seems to be working appropriately now!

Link to comment
Share on other sites

  • 2 weeks later...

Thank you joshabts!

 

This setup works for me as well. Only point I would add to those instructions is make sure the firewall on your server/web host provider allows SMTP connections outbound on port 587 to smtp.gmail.com.

 

Initially my provider (Site5) did not allow for this and I had to get them to add these settings to their firewall whitelist.

 

Tip: smtp.gmail.com is actually a CNAME for gmail-smtp-msa.l.google.com which itself resolves to numerous A records. Make sure you whitelist all of them.

Link to comment
Share on other sites

  • 3 weeks later...

Thanks, this helped me to get tls operational to my smtp relay.

 

Enabling postfix port 587 and choosing ssl, which would be the logical approach given the user interface options provided, resulted in the following conversation between my whmcs server and my postfix server:

 

> my.whmcsserver.com[xxx.xxx.xxx.xxx]: 220 my.smtprelay.com ESMTP Postfix (Ubuntu)
< my.whmcsserver.com[xxx.xxx.xxx.xxx]: ?d???
match_string: ?d??? ~? CONNECT
match_string: ?d??? ~? GET
match_string: ?d??? ~? POST
match_list_match: ?d???: no match
> my.whmcsserver.com[xxx.xxx.xxx.xxx]: 502 5.5.2 Error: command not recognized

 

Or, outside the debug environment, the conversation looks like this:

connect from my.whmcsserver.com[xxx.xxx.xxx.xxx]
lost connection after UNKNOWN from my.whmcsserver.com[xxx.xxx.xxx.xxx]
disconnect from my.whmcsserver.com[xxx.xxx.xxx.xxx]

 

Now it's entirely possible that I failed to configure my postfix correctly, because it's late and I didn't spend a lot of time investigating. However, my smtp server does sasl + tls perfectly well on port 25 (for ages) so all the certs and keys are properly configured and well used. All I did was enable the submission option in master.cf.

 

In any event, ?d??? is not a valid initial connection string where HELO/EHLO would be anticipated, so hopefully someone in a position to fix this problem (if it is indeed one) will happen along here and comment accordingly.

 

And thanks again for the hint to edit the class.phpmailer.php file.

Link to comment
Share on other sites

ARRRRGGGHHH --- I have followed this post word by word from page 2 (as I am using WHMCS v.4.1 )...

 

I was excited to see this is working! But when I tried to follow steps it didn't work for me?

 

I edited class.phpmailer.php to

var $SMTPSecure = "tls";

 

I then set debug on to try and solve this, this is the result of my debugging:

 

SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "220 mx.google.com ESMTP l38sm8338505waf.61 "

SMTP -> get_lines(): $data is "220 mx.google.com ESMTP l38sm8338505waf.61 "

SMTP -> FROM SERVER: 220 mx.google.com ESMTP l38sm8338505waf.61

SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] "

SMTP -> get_lines(): $str is "250-SIZE 35651584 "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 "

SMTP -> get_lines(): $str is "250-8BITMIME "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME "

SMTP -> get_lines(): $str is "250-STARTTLS "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS "

SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES "

 

SMTP -> get_lines(): $str is "250 PIPELINING "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250

 

PIPELINING "

SMTP -> FROM SERVER: 250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250 PIPELINING

 

SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS "

SMTP -> get_lines(): $data is "220 2.0.0 Ready to start TLS "

SMTP -> FROM SERVER: 220 2.0.0 Ready to start TLS

SMTP -> FROM SERVER:

SMTP -> ERROR: RSET failed:

SMTP -> FROM SERVER:

SMTP -> ERROR: EHLO not accepted from server:

SMTP -> FROM SERVER:

SMTP -> ERROR: HELO not accepted from server:

SMTP -> ERROR: AUTH not accepted from server:

SMTP -> NOTICE: EOF caught while checking if connected

 

Email Sending Failed - SMTP Error: Could not connect to SMTP host.

 

Email Sending Completed

Link to comment
Share on other sites

Okay so I read the whole thread from page 1.... I use Google Aps mail system for my small business and have just purchased a WHMCS license to handle my billing etc... (I run a small consulting firm) I am using WHMCS v4.1 so I "think" that the code has been applied already to class.phpmailer.php...

 

I edited the file to add:

 

var $SMTPSecure = "tls";

 

And I followed JOSHABTS directions to setup GENERAL->MAIL settings to match what worked for him... But I get the error:

 

Email Sending Failed - SMTP Error: Could not connect to SMTP host.

 

Email Sending Completed

 

I enabled DEBUGGING in the .php file and this is what it reports to me:

 

SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "220 mx.google.com ESMTP l38sm8338505waf.61 "

SMTP -> get_lines(): $data is "220 mx.google.com ESMTP l38sm8338505waf.61 "

SMTP -> FROM SERVER: 220 mx.google.com ESMTP l38sm8338505waf.61

SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] "

SMTP -> get_lines(): $str is "250-SIZE 35651584 "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 "

SMTP -> get_lines(): $str is "250-8BITMIME "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME "

SMTP -> get_lines(): $str is "250-STARTTLS "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS "

SMTP -> get_lines(): $str is "250-ENHANCEDSTATUSCODES "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES "

SMTP -> get_lines(): $data was "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES "

 

SMTP -> get_lines(): $str is "250 PIPELINING "

SMTP -> get_lines(): $data is "250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250

 

PIPELINING "

SMTP -> FROM SERVER: 250-mx.google.com at your service, [MY.PUB.IP.ADDR] 250-SIZE 35651584 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250 PIPELINING

 

SMTP -> get_lines(): $data was ""

SMTP -> get_lines(): $str is "220 2.0.0 Ready to start TLS "

SMTP -> get_lines(): $data is "220 2.0.0 Ready to start TLS "

SMTP -> FROM SERVER: 220 2.0.0 Ready to start TLS

SMTP -> FROM SERVER:

SMTP -> ERROR: RSET failed:

SMTP -> FROM SERVER:

SMTP -> ERROR: EHLO not accepted from server:

SMTP -> FROM SERVER:

SMTP -> ERROR: HELO not accepted from server:

SMTP -> ERROR: AUTH not accepted from server:

SMTP -> NOTICE: EOF caught while checking if connected

 

Email Sending Failed - SMTP Error: Could not connect to SMTP host.

 

Email Sending Completed

Link to comment
Share on other sites

Okay I racked my brain all day with this until I found a totally unrelated post that mentioned "openssl compiled in PHP"...

 

With no other options I decided to recompile apache/php (and I hate doing this)...

 

But I added the OPENSSL module and now following directions here in the thread I TOO sucessfully use Google Aps for my domain e-mail and it integrates nicely with WHMCS...

 

EDIT the class.phpmailer.php file and ensure "tls" is set as the variable...

 

Then just set GENERAL->MAIL settings as follows:

 

MAIL: SMTP

Server: smtp.gmail.com

Port: 587 (or 465)

UN: username@domain.com

PW: gmail password

 

LEAVE SSL UNCHECKED.

 

WORKS A TOOT. THANKS GUYS!

 

 

EDIT: OPENSSL allows the socket for TLS....

Edited by sierradump
NOTE ON PHP MODULE "OPENSSL"
Link to comment
Share on other sites

  • 3 weeks later...

Ok, this all depends on your server configuration and firewall, and you should check ssl as Google requires it. You can use either port 587 or 465, I use 465 as that's what my host had opened in the firewall, either way make sure one of those ports is open before attempting this.

 

Screenshot: http://i30.tinypic.com/dpalg0.png

 

More info:

 

http://mail.google.com/support/bin/answer.py?hl=en&answer=13287

 

Also, I think this isn't possible but I'll ask, has anyone configured the outgoing smtp mail to be sent by mydomain.com instead of gmail.com? If I just send email via google apps it shows as sent by my domain, but when I use smtp with google apps it shows as sent by gmail :|

Link to comment
Share on other sites

  • 5 months later...

Hello All,

 

I read through all of the postings and have been juggling my settings for the last week.

 

At this point I have configured all of my SMTP settings as required and still cannot get WHMCS to connect to the SMTP host. It's a dead stick.

 

I had my host whitelist the smtp.gmail.com address and port 587 in their firewall and have played with every possible configuration that might have allowed it to work but no joy.

 

Has anyone gotten gmail in particular Google App's version of gmail to work using SMTP?

 

On that note, has anyone gotten POP3 to work using a gmail account in their service departments?

 

Thanks for any help you can provide.

Link to comment
Share on other sites

  • 7 months later...

There is no reason in 2010 that software authors should not try to use SSL/TLS for both email and FTPES. We have an unreleased osCommerce fork we're authoring that WILL use these secure methods. I hope WHMCS shall do the same.

 

FYI: You CAN purchase something like positiveSSL or rapidSSL for the server's services (email, control panel, ftp, etc) Make sure to disable SSL V2 and only allow MED/HIGH encryption. and disable pop3d and imapd (insecure daemons) and in your ftp server, disable clear text authentication and clear text data channels.

Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated