Can't get outbound email working in self-hosted SugarCRM 6.5 - sugarcrm

I can't seem to get outbound email working from my SugarCRM installation, with only the message SMTP connect() failed appearing in the logs.
I've set my smtp server to smtp.gmail.com, email address, password, TLS, port 587. When I go to 'Send Test Email' I get the error.
I've set my local hostname, installed openssl, set the host_name in config.php and included it as a referrer in config_override.php. I've also tried setting SMPTDebug to 2 in SugarPHPMail.php but that seemed to have no effect.
When I run openssl s_client -starttls smtp -crlf -connect smtp.gmail.com:587 the output includes Verify return code: 0 (ok) and I don't know where to go from here. I can connect via telnet to that host & port and get a 220 SMTP message back as expected.
I do also have an exchange server available, but haven't been able to get that one working either, and thought Gmail would be more easily-solved.
I'm on Sugar 6.5.26 hosted on Linux (Debian, Raspbian).

Ok I found the solution while looking for the 'Allow less secure apps' setting in Gmail.
I have two-step authentication switched on in my Gmail account, which will obviously complicate things but had slipped my mind. Therefore I needed to use an app-specific password, and not my normal Gmail password.
As soon as I created an app-specific password in Google (at https://myaccount.google.com/apppasswords) and plugged that into the SugarCRM settings, it worked fine. D'oh!

Related

SSL for mail server

I don't know if I am asking this in the right place.
I have an SSL cert for my website, and I am trying to setup a mail server (same domain) using the same cert.
I am using Postfix and Dovecot. When I try logging in from Evolution mail client, I get an error "Peer failed to perform TLS handshake". When I try an online service to verify I get "Recipient address rejected: User unknown in local recipient table."
I guess my actual question is, can I actually use the same SSL cert for my website and my email server?
What do I do to debug next?
You can use a certificate you have for the web server also for your mail server as long as it matches the hostname you use to access your mail server. Of course the certificate need to properly setup at the mail server, i.e. include the necessary intermediate certificates similar to how it is (hopefully) setup on the web server.
I am using Postfix and Dovecot.
This means you need to take care of multiple configurations, both for SMTP in Postfix and IMAP/POP3 (whatever you use) in Dovecot. And in all cases the certificates subject/SAN must match the hostname you use to connect to the server.
When I try logging in from Evolution mail client, I get an error "Peer failed to perform TLS handshake".
There are not enough information about this setup to find out what exactly is causing the TLS error. It is not even clear if the error is caused when retrieving mail (IMAP/POP3, i.e. Dovecot) or while sending (Postfix).
When I try an online service to verify I get "Recipient address rejected: User unknown in local recipient table."
This has nothing to do with TLS at all. The test server simply tried to use a recipient which your mail server (Postfix) will not accept.
What do I do to debug next?
The next steps would probably be to check if the certificate matches the names you use in the first place and to look into log files for error messages or warnings. Following steps depend on what the result of these steps is.

use smtp.mydomain.com to forward to smtp.gmail.com?

I am using google apps for email. I can send email out through c# code fine with smtp.gmail.com.
I would like to be able to use the name smtp.mydomain.com instead, but still have it go to smtp.gmail.com. I tried just seeing a CNAME in my DNS settings, but I get this error:
"The remote certificate is invalid according to the validation procedure."
Any ideas?
Thanks.
Yes, you can't, the TLS certificate used to communicate privately with the remote SMTP server is signed with smtp.gmail.com. The only solution is to create a SMTP relay with sendmail for example on your own server.

Gmail smtp configuration for Drupal 7

I want to send email in Drupal 7. So, does anyone know how to configure Gmail SMTP on Drupal 7?
Download SMTP module and enable it.
Go to Admin > Configuration > SMTP authentication support and set the following values:
Turn on the module at the Install options fieldset at the top.
SMTP server settings:
smtp server: smtp.gmail.com
smtp backup server: leave blank.
smtp port: 465
use encrypted protocol: select "use SSL"
SMTP authentication:
Enter a valid Gmail email address and password.
Email options:
Set the same email address that you used at SMTP Authentication. Using a different account is called Phishing
Send test email: set an email to receive a sample email.
Enable debugging: yes.
3. Click on submit and verify that the email was submitted and that you received it. If not, read carefully the debug information at the top of the screen. Once satisfied, remember to deactivate the debug checkbox.
Step 1: Download SMTP module and enable it.
Step 2: Go to Admin > Configuration > System > SMTP authentication support and set the following values:
Turn this module on or off: On.
SMTP server settings:
smtp server: smtp.gmail.com
smtp backup server: leave blank.
smtp port: 465
use encrypted protocol: select "use SSL"
SMTP authentication:
Enter a valid Gmail email address and password.
Email options:
Set the same email address that you used at SMTP Authentication.
Send test email: set an email to receive a sample email and to test whether the module is working.
Enable debugging: yes.
Step 2a(Optional): Allow Less Secure Apps Access which is here: http://www.google.com/settings/security/lesssecureapps
Step 3: Click on Save and go to your inbox to check. If there is an testing email then it is fine.
Note: Your email address provided in your smpt setting MUST be the same like in your site information.
I hope SMTP Authentication Support module will help you.
For me, just following the steps in Juampy's answer didn't work. The error "Unable to send mail. Contact site administrator." continued to display. Do the following first and then configure SMTP module as per his answer.
Before installing SMTP module, download PHPMailer and extract it. Rename the folder as 'phpmailer' and copy the folder into module folder of SMTP module. Then, install the SMTP module.
An alternative configuration is as follows:
smtp port: 587
use encrypted protocol: select "use TLS"
This blog entry has some more up-to-date info:
http://www.stevepolitodesign.com/blog/drupal-configure-smtp-module-work-gmail-updated
Install and set-up module:
Install the SMTP Authentication Support module in the usual way.
Navigate to the configuration page admin/config/system/smtp
Under Turn this module on or off select On. You can leave Send mail
by queue and Retry sending mail on error. deselected by default, but
selecting them won't affect Gmail.
Under SMTP server enter the following smtp.gmail.com. Leave SMTP
backup server blank
Under SMTP port enter 587 ​
Under Use encrypted protocol select Use TLS ​
Under SMTP AUTHENTICATION enter a Gmail address and password.
Under E-MAIL OPTIONS use the same Gmail address as you did above and
enter an E-mail from name
Click Save
Update gmail account settings:
Login to your Gmail account at https://myaccount.google.com/
On the account homepage, click Sign-in & security or navigate to https://myaccount.google.com/security
Scroll down to the Allow less secure apps: widget, and have it enabled.
Now navigate to https://accounts.google.com/DisplayUnlockCaptcha and click Continue
Go back to the SMTP configuration page admin/config/system/smtp
Enter an email address you would like to receive a test message from and click Save configuration
Check your inbox to confirm you received the test message.

Dotproject

I Have install dot project on linux machine. using ssmtp for gmail account to sending emails for mails notifications . but when i create any user it doesn't send mails to user email ID for account creation. but i send maail form shell prompt.the error i am getting is Failed to send email: 530 5.7.0 Must issue a STARTTLS command first. 22sm11794837wfd.6 added :( . Please help me if any one have solution....
Gmail requires a secure connection (TLS or SSL).
You need to configure SSMPT (not dotProject) to talk securely with Google's SMTP server.
I think you can just add the following to your ssmtp.conf file and (assuming your SSMTP package was compiled with SSL support) it should then work:
UseTLS=YES
Or perhaps:
UseSTARTTLS=YES
More info here.
I assume "530 5.7.0 Must issue a STARTTLS command first." means that you have to connect with TLS (Transport Layer Security). Does dot project support that?

Windows scripting to email using TLS

I'm trying to make an SVN post-commit script that makes backups to a Gmail drive. Blat doesn't seem to support TLS. Are there any good scripting programs on windows that can send an email via TLS?
I don't know about other mail senders, but stunnel is able to accept a plain text connection and tunnel it through an SSL connection. You can have it listen on localhost:25 and make an SSL connection to an smtps server (tcp/465). I have used it in a similar situation where a WebDAV client didn't support SSL.
The blat folks are saying the stunnel is the best bet for tls support but i've found that gmail doesn't require tls to send mail. Now, the data may not be encrypted but I send out email via my account (to other gmail accounts only) all the time as an automated process and it works great. if you need it let me know and i'll drop in the command-line parms.