EmailDiscussions.com  

Go Back   EmailDiscussions.com > Discussions about Email Services > Setting up/running an email service
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
Stay in touch wirelessly

Setting up/running an email service If you're setting up an email service from scratch, or running one, exchange ideas and tips with other Webmasters here...

Reply
 
Thread Tools
Old 15 Oct 2016, 01:09 AM   #1
SipriusPT
Junior Member
 
Join Date: Oct 2016
Posts: 3
Question Noob problem with relay outgoing mail through ISP

Hello guys,

I pretty new on setting up webservices and i only have basic (CCNA 1º module) knowledge on networks , and i am trying to set one web service on a local server, to receive and send mail through an mail server hosted in my ISP.

Setup:
- OSX
- Roundcubemail
- Server app
- Dinamic IP with No-IP link

Here is my default.inc.php:

Quote:
/ ----------------------------------
// SMTP
// ----------------------------------

// SMTP server host (for sending mails).
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// If left blank, the PHP mail() function is used
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld

$config['smtp_server'] = ‘%n’;
// $config['smtp_server'] = ‘’;

// SMTP port (default is 25; use 587 for STARTTLS or 465 for the
// deprecated SSL over SMTP (aka SMTPS))

$config['smtp_port'] = 25;

// SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login

$config['smtp_user'] = '%u';

// $config['smtp_user'] = '';

// SMTP password (if required) if you use %p as the password Roundcube
// will use the current user's password for login

$config['smtp_pass'] = '%p';

// $config['smtp_pass'] = '';

// SMTP AUTH type (DIGEST-MD5, CRAM-MD5, LOGIN, PLAIN or empty to use
// best server supported one)

$config['smtp_auth_type'] = ‘LOGIN’;
// $config['smtp_auth_type'] = ‘’;

// Optional SMTP authentication identifier to be used as authorization proxy
$config['smtp_auth_cid'] = null;

// Optional SMTP authentication password to be used for smtp_auth_cid
$config['smtp_auth_pw'] = null;

// SMTP HELO host
// Hostname to give to the remote server for SMTP 'HELO' or 'EHLO' messages
// Leave this blank and you will get the server variable 'server_name' or
// localhost if that isn't defined.
$config['smtp_helo_host'] = '';

// SMTP connection timeout, in seconds. Default: 0 (use default_socket_timeout)
// Note: There's a known issue where using ssl connection with
// timeout > 0 causes connection errors (https://bugs.php.net/bug.php?id=54511)
$config['smtp_timeout'] = 0;

// SMTP socket context options
// See http://php.net/manual/en/context.ssl.php
// The example below enables server certificate validation, and
// requires 'smtp_timeout' to be non zero.
// $config['smtp_conn_options'] = array(
// 'ssl' => array(
// 'verify_peer' => true,
// 'verify_depth' => 3,
// 'cafile' => '/etc/openssl/certs/ca.crt',
// ),
// );
$config['smtp_conn_options'] = null;
And i am getting a:
Quote:
SMTP Error (250): Authentication failed.
Without being possible to send mails to no one.

And If i change those to default:

Quote:
$config['smtp_server'] = ‘’;
$config['smtp_port'] = 25;
$config['smtp_user'] = '';
$config['smtp_pass'] = '';
$config['smtp_auth_type'] = ‘’;
I would have a different output, here i am able to send and receive mails between my several domains in my ISP, but i am unable to send mails to domains such as gmail.com, receiving the following error:

Quote:
SMTP Error (550): Failed to add recipient "XXX" (Please turn on SMTP Authentication in your mail client.
XXX (XXX.local) [XXX]:XXX
is not permitted to relay through this server without authentication.).
I discover that SMTP works with authentication through SPF but i dont know how to set it up in my local server and/or my cpanel in my ISP

Last edited by SipriusPT : 15 Oct 2016 at 01:42 AM.
SipriusPT is offline   Reply With Quote

Old 15 Oct 2016, 03:05 AM   #2
mailcheap
Junior Member
 
Join Date: Oct 2016
Location: CZ & USA
Posts: 21
Mailservers don't allow you to send emails to outside domains/mailservers without authentication; otherwise it would be an open relay!

Authenticate using PHPMailer or similar. Example below:

$mailServerType = 'smtp';
$smtp_server = 'example.mymailcheap.com';
$smtp_user = 'user1@example.com';
$smtp_pw = 'UserPassword';
$smtp_port = 587;
$smtp_security = 'tls';
mailcheap is offline   Reply With Quote
Old 17 Oct 2016, 06:10 PM   #3
SipriusPT
Junior Member
 
Join Date: Oct 2016
Posts: 3
Quote:
Originally Posted by mailcheap View Post
Mailservers don't allow you to send emails to outside domains/mailservers without authentication; otherwise it would be an open relay!

Authenticate using PHPMailer or similar. Example below:

$mailServerType = 'smtp';
$smtp_server = 'example.mymailcheap.com';
$smtp_user = 'user1@example.com';
$smtp_pw = 'UserPassword';
$smtp_port = 587;
$smtp_security = 'tls';
Thank you mailcheap.

Do i need to create a dedicated script for it? because i think it should authenticate through default.inc.php (as you can see above) =/

Do i need some kind of key to sign my mails? I have read a lot of stuff from SPF and DKIM but i dont know if that is the problem,or if i can solve it with that, and if yes how can i do it.

UPDATE1:

I have activated a smtp log:

Quote:
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 220-cpanel.X.pt ESMTP Exim 4.87 #1 Mon, 17 Oct 2016 11:16:24 +0100
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 220-We do not authorize the use of this system to transport unsolicited,
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 220 and/or bulk e-mail.
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Send: EHLO X.local
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 250-cpanel.X.pt Hello X.pt [X]
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 250-SIZE 52428800
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 250-8BITMIME
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 250-PIPELINING
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 250-AUTH PLAIN LOGIN
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 250-STARTTLS
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 250 HELP
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Send: RSET
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 250 Reset OK
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Send: QUIT
[17-Oct-2016 11:16:24 +0100]: <sbg56vpg> Recv: 221 cpanel.X.pt closing connection
UPDATE2:

I have people in this network working with outlook, and they use their creds both to SMTP and IMAP :-\ Now i am almost 100% that the problem must be from my local server.

UPDATE3:

It seems that i have bypass those errors, but still i am not receiving any mails in the outside email account, i am just able to send mails inside of my ISP. What i have done was playing with mail server link, this was the set:

config.inc.php:
Quote:
// ----------------------------------
// IMAP
// ----------------------------------
// The mail host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
// required to match old user data records with the new host.
$config['default_host'] = 'mail.X.pt';

(...)

// ----------------------------------
// SMTP
// ----------------------------------
// SMTP server host (for sending mails).
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// If left blank, the PHP mail() function is used
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld

$config['smtp_server'] = ‘%h’;
defaults.inc.php:
Quote:
// ----------------------------------
// IMAP
// ----------------------------------

// The mail host chosen to perform the log-in.
// Leave blank to show a textbox at login, give a list of hosts
// to display a pulldown menu or set one host as string.
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// Supported replacement variables:
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %s - domain name after the '@' from e-mail address provided at login screen
// For example %n = mail.domain.tld, %t = domain.tld
// WARNING: After hostname change update of mail_host column in users table is
// required to match old user data records with the new host.
$config['default_host'] = 'mail.X.pt';

(...)

// ----------------------------------
// SMTP
// ----------------------------------

// SMTP server host (for sending mails).
// To use SSL/TLS connection, enter hostname with prefix ssl:// or tls://
// If left blank, the PHP mail() function is used
// Supported replacement variables:
// %h - user's IMAP hostname
// %n - hostname ($_SERVER['SERVER_NAME'])
// %t - hostname without the first part
// %d - domain (http hostname $_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld
$config['smtp_server'] = ‘%h’;

Last edited by SipriusPT : 18 Oct 2016 at 01:13 AM.
SipriusPT is offline   Reply With Quote
Old 18 Oct 2016, 09:24 PM   #4
SipriusPT
Junior Member
 
Join Date: Oct 2016
Posts: 3
I FINALLY found what was doing this, it was my server app, i had to leave Mail turned on but without any relay outgoing mail through ISP activated, and i could not leave Mail turned off.
SipriusPT is offline   Reply With Quote
Reply


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +9. The time now is 05:46 PM.

 

Copyright EmailDiscussions.com 1998-2022. All Rights Reserved. Privacy Policy