Resolved MediaWiki SMTP error

Status
Not open for further replies.

costas1

Member
Messages
134
Reaction score
3
Points
18
Trying to send a confirmation email via MediaWiki ends in error:

Mediawiki could not send your confirmation mail. Please check your email address for invalid characters.
Mailer returned: Failed to connect to mail.[domain]:587 [SMTP: Failed to connect socket: Connection refused (code: -1, response: )]


My code:


$wgSMTP = [

'host' => 'mail.[domain]',

'IDHost' => '[domain]',

'port' => 587,

'auth' => true,

'username' => '[username]@[domain]',

'password' => '[password]'

];

Mediawiki uses PEAR Net_SMTP extension, by the way, which may not be installed on the server. Am I right? If yes is there an alternative?
 
Last edited:

costas1

Member
Messages
134
Reaction score
3
Points
18
Right now I see that your requests are going through CloudFlare, and CloudFlare does not handle port 587. This is for your website s***n.com .

https://support.cloudflare.com/hc/e...work-ports-compatible-with-Cloudflare-s-proxy

So, you can use x12.x10hosting.com as the server, or you will have to fiddle around with CloudFlare as suggested by them in the link I provided.

I have the Mediawiki, which has the connection problem, installed in my other domain. Does the same apply for it too?

The question is why does Cloudflare serves email requests. In Cloudflare's DNS settings I have an A record for [domain] which points to x12 server's IP and a CNAME record for www.[domain] which points to [domain], so I'm not sure if that's the case for the wiki.

For s***n.com indeed Cloudflare had autocreated an MX DNS entry which still exists, but there is no MX entry for the other domain which is associated with Mediawiki.
 

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
mail.yourdomain.com does point to cloudflare servers, cloudflare will NOT handle traffic for anyting but the website and will not put the mail.yourdomain.com as a passthrough unless you tell it to (ie the A record for it must be in DNS of cloudflare but can NOT be proxied).

Right now your script would try to connect to a smtp server located on cloudflares proxyserver, which does not exist.

Another issue is that your domain, without cloudflares proxy, does not handle SSL in itself, which means you can not connect SMTP on the secure port. To be able to use that you would need to use the server address as the hostname (which also solves the problem with attempting to connect a non existing mailsevrer on cloudflares proxy network).
 

costas1

Member
Messages
134
Reaction score
3
Points
18
mail.yourdomain.com does point to cloudflare servers, cloudflare will NOT handle traffic for anyting but the website and will not put the mail.yourdomain.com as a passthrough unless you tell it to (ie the A record for it must be in DNS of cloudflare but can NOT be proxied).

Right now your script would try to connect to a smtp server located on cloudflares proxyserver, which does not exist.

Another issue is that your domain, without cloudflares proxy, does not handle SSL in itself, which means you can not connect SMTP on the secure port. To be able to use that you would need to use the server address as the hostname (which also solves the problem with attempting to connect a non existing mailsevrer on cloudflares proxy network).

Thanks for the help! Indeed using x10hosting's server's address solved the issue.

If I got that right:

mail.yourdomain.com as a passthrough unless you tell it to (ie the A record for it must be in DNS of cloudflare but can NOT be proxied

creating an A record in Cloudflare's DNS settings about mail.yourdomain.com and associating it with x10hosting's mail server would also work as a solution (if there isn't a separate issue with the ports Cloudflare handles)? Just asking theoretically, because if Cloudflare is not acting as a proxy the traffic, probably there is no benefit by doing so.
 

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
Setting the DNS on cloudflare would be absolutely needed for mail.yourdomain.com to work as I assume you use cloudflares name servers (otherwise it would not properly point anywhere).

The key part is that it can not be going through the proxy.
 

costas1

Member
Messages
134
Reaction score
3
Points
18
Setting the DNS on cloudflare would be absolutely needed for mail.yourdomain.com to work as I assume you use cloudflares name servers (otherwise it would not properly point anywhere).

The key part is that it can not be going through the proxy.

In my initial code

$wgSMTP = [

'host' => 'mail.[domain]',

'IDHost' => '[domain]',

'port' => 587,

'auth' => true,

'username' => '[username]@[domain]',

'password' => '[password]'

];

I just changed the 'host' => 'mail.[domain]' to host' => 'x12.x10hosting.com' and MediaWiki succesfully sent the confirmation email this time, without making any changes to Cloudflare.

Do you mean that I should leave the host entry of the array with my domain assigned to it and that I should create an A entry for mail.yourdomain.com at Cloudflare's DNS settings as a more appropriate solution?

edit: Indeed, I use Cloudflare and I have 2 entries in total both proxied:
  1. A entry that points [domain] to x10hosting's server's address.
  2. CNAME entry that points www.[domain] to [domain]
I have no other entries. The wiki managed to sent the email with just changing the host in my code, without adding any entries to Cloudflare.
 
Last edited:

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
Having the server name as host will work fine and for now I'd leave it at that in your case, as that is the only option that can use secure port.

However, in the unlikely event that you would end up being moved to another server at some point, you will need to update that setting.

IF you want to use mail.yourdomain.com, there needs to be an entry for it at cloudflare.
 

costas1

Member
Messages
134
Reaction score
3
Points
18
Having the server name as host will work fine and for now I'd leave it at that in your case, as that is the only option that can use secure port.

However, in the unlikely event that you would end up being moved to another server at some point, you will need to update that setting.

IF you want to use mail.yourdomain.com, there needs to be an entry for it at cloudflare.

Well, OK. As it works I also consider it solved, but out of curiosity which entry should be added to the Cloudflare settings?
 
Last edited:

costas1

Member
Messages
134
Reaction score
3
Points
18
I have an A entry with the server's IP.
I also have a CNAME for www.[domain]
I added a 2nd CNAME for mail.[domain] with proxing disabled as in your account, but it doesn't seem to work. Maybe there is a conflict with the other 2 I guess.
 

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
the mail.yourdomain.com does ping to the proxy server for me right now.

You would either have an A record or a CNAME for mail, having both will cause a conflict.

The entire list for my setup is: https://www.screencast.com/t/9DEgefLyeLkB

Note that there are no duplicates.
 

costas1

Member
Messages
134
Reaction score
3
Points
18
the mail.yourdomain.com does ping to the proxy server for me right now.

You would either have an A record or a CNAME for mail, having both will cause a conflict.

The entire list for my setup is: https://www.screencast.com/t/9DEgefLyeLkB

Note that there are no duplicates.

I have only 2 entries in Cloudflare's DNS settings:
  1. A record for [domain].org which in the content's filed have the server's IP.
  2. A CNAME for www which in the content's field I have [domain].org
both entries have an auto TTL and are proxied.

I tried adding a 3rd entry: CNAME for mail with x12.x10hosting.com in the content's field with proxy disabled, while having host set as 'mail.[domain].org' in Wikimedia's configuration file. That resulted in error.
 

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
mail.[domain].org will not be able to use secure, you probably need port 25 which is the regular non secureport
 

costas1

Member
Messages
134
Reaction score
3
Points
18
mail.[domain].org will not be able to use secure, you probably need port 25 which is the regular non secureport

I set 'port' => 25. 'host' => mail.[domain].org and I added the 3 entry in Cloudflare's DNS settings.

I got this error:

Mailer returned: authentication failure [SMTP: STARTTLS failed (code: 220, response: TLS go ahead)]

Anyway, as far as I'm concerned you can set the thread as resolved. I can accept the already working solution with x12 server in my configuration file.
 

Anna

I am just me
Staff member
Messages
11,733
Reaction score
578
Points
113
I'll mark this as resolved then.
 
Status
Not open for further replies.
Top