mail not working

Started by G Star, June 05, 2015, 06:25:44 PM

Previous topic - Next topic

G Star

Hi, i cant seem to get emails to work like registration links, newsletters ect...

I have tried (PhP default) which i get no errors in the log and says its sent but email never comes.

tested with this
<?php

$mail 
mail("YOUR-EMAIL-HERE""wahahahahahaahahahahaa","I like spamming your inbox!!!""From: Myself<[email protected]");

if(!
$mail){
echo 'mail is not sent!';
} else {
echo 'mail is sent :-)';
}


and it says mail has sent!

I have also tried smtp countless times using gmail but i get this error
Couldn't get mail server response codes

Found a post about changing this code in subs-post.php

if ($modSettings['mail_type'] == 1 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
    {
        // !!! These should send the CURRENT server's name, not the mail server's!

        // EHLO could be understood to mean encrypted hello...
        if (server_parse('EHLO ' . $modSettings['smtp_host'], $socket, null) == '250')
        {
            if (!server_parse('AUTH LOGIN', $socket, '334'))
                return false;
            // Send the username and password, encoded.
            if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
                return false;
            // The password is already encoded ;)
            if (!server_parse($modSettings['smtp_password'], $socket, '235'))
                return false;
        }


To this

if ($modSettings['mail_type'] == 1 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
    {
        // !!! These should send the CURRENT server's name, not the mail server's!

        // EHLO could be understood to mean encrypted hello...
        if (server_parse('EHLO ' . $modSettings['smtp_host'], $socket, null) == '250')
        {
            //STARTTLS
            server_parse('STARTTLS', $socket, null);
            stream_socket_enable_crypto($socket,true,STREAM_CRYPTO_METHOD_TLS_CLIENT);
            server_parse('EHLO ' . $modSettings['smtp_host'],$socket,null);

            if (!server_parse('AUTH LOGIN', $socket, '334'))
                return false;
            // Send the username and password, encoded.
            if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
                return false;
            // The password is already encoded ;)
            if (!server_parse($modSettings['smtp_password'], $socket, '235'))
                return false;
        }


But i still get the same error.

I also tried making my own mail server with hMailServer-5.6.3-B2249 & Thunderbird Setup 17.0.5 following this tutorial

duyhung.1055016.n5.nabble com/How-to-Setup-localhost-email-server-using-hMailServer-and-Thunderbird-td5704501.html

For which i get the error code
Ran into problems sending Mail. Error: 503 Bad sequence of commands

I have searched for 7+ hours on here and google and still haven't found a solution any help would be much appreciated as my forum is pretty useless with out it.

I host my forum on a dedicated server on my home network on a windows pc with the latest Apache, PhP & MySQL and my SMF version is 2.0.10, any other info you would like to know just ask and i will do my best to get it!

I would prefer if i didn't have to start all over again as i have spent quite a while setting the forum up to how i want it.
Thanks guys 

G Star

More details of my server:

Server version: Apache/2.4.12 (Win32) OpenSSL/1.0.1l PHP/5.6.8 /MySQL version: 5.6.24

Chas Large

Enable the mail queue so you can see what's happening when the site sends mail.

If you're using SMTP and it's failing to send mail then try prefixing your mail server with ssl:// or tls://

What exactly is the error message you mentioned in the latter part of your post.
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

G Star

Quote from: Chas Large on June 06, 2015, 06:53:36 AM
Enable the mail queue so you can see what's happening when the site sends mail.

If you're using SMTP and it's failing to send mail then try prefixing your mail server with ssl:// or tls://

What exactly is the error message you mentioned in the latter part of your post.

I enabled queue and it displays the info ect.. i get no errors in the log but i still don't receive the email.

I tried prefixing SMTP with ssl:// &  tls:// but neither worked.

That error was in the log when i tried sending emails through my own SMTP mail server (i may not of set up the mail server right i don't know)

I can't/don't know how to get anymore information about it.


Illori

do you have php.ini set to use sendmail? do you have sendmail installed?

G Star

Quote from: Illori on June 06, 2015, 02:19:55 PM
do you have php.ini set to use sendmail? do you have sendmail installed?

Yes its installed with apache but im not quite sure how to set it up or if its enabled, do i still need a SMTP server?

青山 素子

You don't necessarily need an SMTP server, but you need to make sure the "sendmail" command works properly on the server. Alternately, you can ask your hosting company if they have a relay you can use.

For GMail, you need to turn on two-factor authentication and use an application specific password, as Google is discontinuing basic SMTP with just a normal password for all standard accounts.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


G Star

#7
Quote from: 青山 素子 on June 06, 2015, 10:22:58 PM
You don't necessarily need an SMTP server, but you need to make sure the "sendmail" command works properly on the server. Alternately, you can ask your hosting company if they have a relay you can use.

For GMail, you need to turn on two-factor authentication and use an application specific password, as Google is discontinuing basic SMTP with just a normal password for all standard accounts.

Is there a way i can test "sendmail"?

I wish i could ask them but i host my own server lol

I did read somewhere about two-factor authentication for Gmail but i couldn't seem to set it up but ill give it another go.

Thanks :)

Edit: I setup two-factor authentication for Gmail and added the info into the settings and i get this error displayed when i try to send mail:
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\Sources\Subs-Post.php on line 1450

Settings i added:

SMTP server = smtp.gmail.com [nofollow]
SMTP port = 465
SMTP username = My Gmail account"
SMTP password = "the long password i got from google"

Edit2: this is my Mail function in PHP.ini do i need to change any of this?

[mail function]
; XAMPP: Comment out this if you want to work with an SMTP Server like Mercury
; SMTP = localhost
; smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost

; XAMPP IMPORTANT NOTE (1): If XAMPP is installed in a base directory with spaces (e.g. c:\program filesC:\xampp) fakemail and mailtodisk do not work correctly.
; XAMPP IMPORTANT NOTE (2): In this case please copy the sendmail or mailtodisk folder in your root folder (e.g. C:\sendmail) and use this for sendmail_path. 
; XAMPP: Comment out this if you want to work with fakemail for forwarding to your mailbox (sendmail.exe in the sendmail folder)
sendmail_path = "\"C:\xampp\sendmail\sendmail.exe\" -t"

; XAMPP: Comment out this if you want to work with mailToDisk, It writes all mails in the C:\xampp\mailoutput folder
;sendmail_path="C:\xampp\mailtodisk\mailtodisk.exe"

; Force the addition of the specified parameters to be passed as extra parameters
; to the sendmail binary. These parameters will always replace the value of
; the 5th parameter to mail(), even in safe mode.
;mail.force_extra_parameters =

; Add X-PHP-Originating-Script: that will include uid of the script followed by the filename
mail.add_x_header=Off

; Log all mail() calls including the full path of the script, line #, to address and headers
;mail.log = "C:\xampp\php\logs\php_mail.log"


And do i have to add Gmail SMTP setting in sendmail.config file?

Sorry for all the questions guys im all out of ideas.

青山 素子

If you're on Windows, sendmail won't work. That's a UNIX thing. PHP on Windows relies on using SMTP. To get this working without setting up a local service, you'll need to use an external mail server. For GMail, you'll want to pull up the topic on using Google and just use the app-specific password rather than your main account password. It should, in theory, work. I've never tested it as I don't usually host on Windows, and XAMPP isn't a good idea for production use (major security issues with how it sets things up by default).
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


G Star

Quote from: 青山 素子 on June 07, 2015, 11:28:23 PM
If you're on Windows, sendmail won't work. That's a UNIX thing. PHP on Windows relies on using SMTP. To get this working without setting up a local service, you'll need to use an external mail server. For GMail, you'll want to pull up the topic on using Google and just use the app-specific password rather than your main account password. It should, in theory, work. I've never tested it as I don't usually host on Windows, and XAMPP isn't a good idea for production use (major security issues with how it sets things up by default).

Yes im on windows 8.1

I tired Gmail with the app-specific password and i get the error i stated above.

What would you recommend instead of XAMPP? i have never used UNIX.

青山 素子

Quote from: G Star on June 08, 2015, 01:33:43 PM
I tired Gmail with the app-specific password and i get the error i stated above.

Here's the settings I just got working for me:

For username, use your full gmail e-mail address. For the password, use the 16 character password you generated.


Quote from: G Star on June 08, 2015, 01:33:43 PM
What would you recommend instead of XAMPP? i have never used UNIX.

If you're not going to have a busy site, a small shared hosting package is low-cost. If you're not experienced with managing servers, you shouldn't do so. Hosting on your own personal computer is especially dangerous because any successful hacking attempt means the attacker has full access to your personal computer. If you're going to host on Windows, you need to be very familiar with how to manually configure all the different components rather than use developer-oriented tools like XAMPP. This is important because tools like XAMPP use things like blank passwords or give full administrator access to the hosted sites to make development easier. Unfortunately, those kinds of things that make development easier also make it very easy for an attacker to exploit.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


G Star

Quote from: 青山 素子 on June 09, 2015, 12:45:01 AM
Quote from: G Star on June 08, 2015, 01:33:43 PM
I tired Gmail with the app-specific password and i get the error i stated above.

Here's the settings I just got working for me:

For username, use your full gmail e-mail address. For the password, use the 16 character password you generated.


Quote from: G Star on June 08, 2015, 01:33:43 PM
What would you recommend instead of XAMPP? i have never used UNIX.

If you're not going to have a busy site, a small shared hosting package is low-cost. If you're not experienced with managing servers, you shouldn't do so. Hosting on your own personal computer is especially dangerous because any successful hacking attempt means the attacker has full access to your personal computer. If you're going to host on Windows, you need to be very familiar with how to manually configure all the different components rather than use developer-oriented tools like XAMPP. This is important because tools like XAMPP use things like blank passwords or give full administrator access to the hosted sites to make development easier. Unfortunately, those kinds of things that make development easier also make it very easy for an attacker to exploit.

Its still not sending mail but i dont get any errors in the log should i change this code back to how it was?


if ($modSettings['mail_type'] == 1 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
    {
        // !!! These should send the CURRENT server's name, not the mail server's!

        // EHLO could be understood to mean encrypted hello...
        if (server_parse('EHLO ' . $modSettings['smtp_host'], $socket, null) == '250')
        {
          //STARTTLS
            server_parse('STARTTLS', $socket, null);
            stream_socket_enable_crypto($socket,true,STREAM_CRYPTO_METHOD_TLS_CLIENT);
            server_parse('EHLO ' . $modSettings['smtp_host'],$socket,null);

            if (!server_parse('AUTH LOGIN', $socket, '334'))
                return false;
            // Send the username and password, encoded.
            if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))
                return false;
            // The password is already encoded ;)
            if (!server_parse($modSettings['smtp_password'], $socket, '235'))
                return false;
        }


To this


if ($modSettings['mail_type'] == 1 && $modSettings['smtp_username'] != '' && $modSettings['smtp_password'] != '')
    {
        // !!! These should send the CURRENT server's name, not the mail server's!

        // EHLO could be understood to mean encrypted hello...
        if (server_parse('EHLO ' . $modSettings['smtp_host'], $socket, null) == '250')
        {
            if (!server_parse('AUTH LOGIN', $socket, '334'))
                return false;
            // Send the username and password, encoded.
            if (!server_parse(base64_encode($modSettings['smtp_username']), $socket, '334'))

G Star

Ignore the post above I'm getting this error

Could not connect to SMTP host: 10060 : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

Also the should i change the code i mentioned in my previous message back to how it originally was? or just leave it?

青山 素子

I would change the code back and see if it works then. You shouldn't have to make any code changes to get this working.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


G Star

Quote from: 青山 素子 on June 10, 2015, 11:30:52 PM
I would change the code back and see if it works then. You shouldn't have to make any code changes to get this working.

Well I changed it back but I'm still getting this error:
Could not connect to SMTP host: 10060 : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

I'm out of ideas as to why I cannot get this to work.

青山 素子

I'm not sure what to tell you. I don't normally run servers on desktop versions of Windows, so I really don't have and ideas.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


G Star

Quote from: 青山 素子 on June 11, 2015, 05:57:51 PM
I'm not sure what to tell you. I don't normally run servers on desktop versions of Windows, so I really don't have and ideas.
That's alright thank you for the help anyway :)

Chas Large

As you're running your home server, I assume you have set up the DNS etc so it can be found on the web. Have you done the same with the MX records so that your mailserver part of the server can send messages.

In order to confirm the server is working, thus isolating the SMF software, what happens if you set up an e-mail account in a mail client like thunderbird. outlook or some other client.

Can that send and receive e0mail through your server? If not then at least you'll know it's not the SMF software.
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

Illori

the op posted already they used a php script outside of SMF to test their mail server, it did not send the email. this is not an SMF specific issue.

Chas Large

Quote from: Illori on June 13, 2015, 06:59:24 AM
the op posted already they used a php script outside of SMF to test their mail server, it did not send the email. this is not an SMF specific issue.
Ah right, shoulda read a bit deeper. I'm outta here. ;D
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

G Star

I initially gave up with SMF when i couldn't get mail to work but yesterday i researched and researched and reconfigured apache send mail settings and hey presto! it works well.... it did for a bit....

I started Mercury and set up a SMTP server with my gmail account.

All was working fine for a few hours then my forum sent a news letter to around 90 people which all went through ok.

But now it has stopped working again, it says they have sent in SMF, it says they sent in Mercury and it even says they sent in gmail but they just don't arrive at the destination emails?

Anyone got any idea? has my gmail account been blacklisted for "spam"?   

青山 素子

If you're sending out mail using Mercury Mail, that must mean you're hosting on Windows and using a home connection. It's possible that your home IP is blacklisted. You can send directly to Google inside SMF and bypass having to use yet another system.

If you are somehow sending through Google with that convoluted setup, you can check your google account directly and see if the messages are showing up as sent.
Motoko-chan
Director, Simple Machines

Note: Unless otherwise stated, my posts are not representative of any official position or opinion of Simple Machines.


G Star

#22
Yea windows 8.1, i tried setting SMF direct to gmail but it doesn't work/connect to gmail, but using "phpmail"(Not "SMTP") with Mercury its sends the email fine my end and in my google account directly they are there under the "sent" section.

I get this error when i try to put SMF direct to gmail
Fatal error: Maximum execution time of 30 seconds exceeded in C:\xampp\htdocs\Sources\Subs-Post.php on line 1445

also i have wordpress installed on the same server but in another directory on on a different domain and that is working granted its alot slower now though taking about 1hour to get the email through where as before it was almost instant.

Advertisement: