Mails with php or ssmtp dont work

Started by s4ph1r3, January 22, 2014, 08:42:32 AM

Previous topic - Next topic

s4ph1r3

Im using lighttpd (webserver), PHP5, MySQL and SMF2.0.6.
Ive been trying to setup sSMTP for mails (new members dont get mail verification) because the default php setting didnt work. But I cant get sSMTP to work, I have tried several guides I found on google but still no luck.
My password doesnt contain any symbols, Im using a secondary gmail password without any symbols in it.
When I try: echo "Test" | mail -s -d "Test" [email protected]
all I get is this error: send-mail: Connection lost in middle of processing.
In SMF error log I have this error: Couldn't get mail server response codes
when someone tries to register.
Does anyone know what Im doing wrong, I dont know what else to try.
Below is my ssmtp conf file (I replaced a few things here with the stuff in capitals).

# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
[email protected]

# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp.googlemail.com:465

# Where will the mail seem to come from?
#rewriteDomain=

# The full hostname
hostname=HOSTNAME

# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
useSTARTTLS=YES
[email protected]
AuthPass=passwithoutsymbols
FromLineOverride=YES
AuthMethod=LOGIN

Storman™

You probably need to exclude a connectivity issue first.

Try using telnet to connect to the server and see what response you get:

telnet smtp.gmail.com:465

or maybe try as well:

telnet smtp.googlemail.com:465

It will either return a load of gobblygook which you can ignore or it will return the message "network unreachable". The former is preferable to confirm connectivity.

Once you confirm connectivity you can relook at your settings.

s4ph1r3

Hi Storman, when I try those commands I get this:
-bash: telnet: command not found
It looks like I need to install something to be able to use those commands?

AllanD

Check out this great sites.
KnD Hosting

s4ph1r3

Ty for your reply AllanD, after installing telnet I tried the commands and got this:
telnet: could not resolve smtp.gmail.com:465/telnet: Name or service not known
telnet: could not resolve smtp.googlemail.com:465/telnet: Name or service not known

Storman™

Something doesn't sound right with your setup. Maybe check that the system hostname as set in /etc/sysconfig/network is also in your hosts file in  /etc/hosts

If you are not sure what it should be then do:

grep HOSTNAME /etc/sysconfig/network

...and find the hostname from the result.

Then find the IP from the result of:

ifconfig

Put the two together in the hosts file on a line after the localhost entries

e.g.     xx.yy.zz.ww    <hostname>

Once done restart network:

# /etc/rc.d/init.d/network restart

or maybe

/etc/init.d/network restart

Then try telnet again...

margarett

Can you also try without ":"?

telnet smtp.gmail.com 465
telnet smtp.googlemail.com 465

In Windows world at least you specify the port number after the host with a space. If you don't specify any, it will use the default 23
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

s4ph1r3

Thanks for the replies. I dont have sysconfig/network in /etc on my Raspberry Pi, will see if that might be somewhere else.

If I type telnet smtp.gmail.com 465 I get this:
Trying 173.194.71.108...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
and after some time this: Connection closed by foreign host.

If I type telnet smtp.googlemail.com 465 I get this:
Trying 74.125.143.16...
Connected to googlemail-smtp.l.google.com.
Escape character is '^]'.
and after some time: Connection closed by foreign host.

What does this mean?

Storman™

QuoteWhat does this mean?

Well that looks promising as its resolving the IP address and making a connection. So it's now back to your settings.

Personally I've never used this with a Google account so it's new ground for me to be honest.

Noticed in your settings that you have both googlemail and gmail, suspect you should use one or the other ??

You currently have:

mailhub=smtp.googlemail.com:465

and

[email protected]

Maybe try with the mailhub as:

mailhub=smtp.gmail.com:465

or

mailhub=smtp.gmail.com 465                                    ^--- with space like margarett mentioned

Apart from that I'm running out of ideas

s4ph1r3

Didnt notice I was using both, thanks for pointing that out :)
Ok so I changed to gmail.com in both places and also tried with space instead of ":" but no luck. I wonder if the problem is with the "." in NAME.NAME@gmail.com or maybe it doesnt work with secondary passwords.
You mentioned that you havent used this with a google account, may I ask what kind of mail service you used?

Storman™

I have my own dedicated smtp server.

Advertisement: