Fresh installation (postfix-dovecote-roundcode) without reserving domain name just VPS IP i can't sent any mail from web but i can sent normally from terminal, it'r return SMTP Error (-1): Connection to server failed
/var/log/mail.log
Jan 7 05:28:04 mail postfix/submission/smtpd[9541]: connect from localhost[127.0.0.1]
Jan 7 05:28:04 mail postfix/submission/smtpd[9541]: lost connection after UNKNOWN from localhost[127.0.0.1]
Jan 7 05:28:04 mail postfix/submission/smtpd[9541]: disconnect from localhost[127.0.0.1]
Jan 7 05:33:06 mail postfix/submission/smtpd[9607]: connect from localhost[127.0.0.1]
Jan 7 05:33:06 mail postfix/submission/smtpd[9607]: lost connection after UNKNOWN from localhost[127.0.0.1]
Jan 7 05:33:06 mail postfix/submission/smtpd[9607]: disconnect from localhost[127.0.0.1]
/var/log/nginx/error.log
2018/01/07 05:33:06 [error] 9504#0: *1 FastCGI sent in stderr: "PHP message: fsockopen(): unable to connect to ssl://mail.test.com:587 (Unknown error) (0):
PHP message: Failed to connect socket: fsockopen(): unable to connect to ssl://mail.test.com:587 (Unknown error) ():" while reading response header from upstream, client: 16.196.246.136, server: , request: "POST /rcm/?_task=mail&_unlock=loading1515303186377&_lang=en&_framed=1 HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock:", host: "", referrer: "https://X.x.x.x/rcm/?_task=mail&_id=5005492295a51afd366fe3&_action=compose"
Conf
root#mail:~# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_size_limit = 0
mydestination = localhost
myhostname = mail.test.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_security_level = may
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/dovecot/dovecot.pem
smtpd_tls_key_file = /etc/dovecot/private/dovecot.pem
smtpd_tls_security_level = may
smtpd_use_tls = yes
virtual_alias_maps = mysql:/etc/postfix/mysql-virtual-alias-maps.cf mysql:/etc/postfix/mysql-virtual-email2email.cf
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
virtual_transport = lmtp:unix:private/dovecot-lmtp
10-master.conf
root#mail:~# grep -v "#" /etc/dovecot/conf.d/10-master.conf
service imap-login {
inet_listener imap {
port = 0
}
inet_listener imaps {
port = 993
ssl = yes
}
}
service pop3-login {
inet_listener pop3 {
port = 0
}
inet_listener pop3s {
port = 995
ssl = yes
}
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
mode = 0600
user = postfix
group = postfix
}
}
service imap {
}
service pop3 {
}
service auth {
unix_listener /var/spool/postfix/private/auth {
mode = 0600
user = postfix
group = postfix
}
unix_listener auth-userdb {
mode = 0600
user = vmail
}
user = dovecot
}
service auth-worker {
user = vmail
}
service dict {
unix_listener dict {
}
}
root#mail:~# hostname
mail
root#mail:~# cat /etc/hosts
127.0.0.1 localhost mail mail.test.com test.com
i found the solution it's on the configuration file
$config['smtp_server'] = 'tls://mail.com'
it should be tls not ssl :)
Shouldn't this:
ssl://mail.test.com:587
be this?
ssl://localhost:587
I believe roundcube needs "localhost" set as the mailserver address, but from the logs it looks to me like it might be set to use "mail.test.com"
If mail.test.com is your VPS - that only exists on IP, not DNS - then there is no way to route to it using that address, so roundcube on the same server will not be able to find it.
If roundcube is on the same server, the mailserver address it uses should be set to "localhost" anyway.
Related
I am using amazon service and created rabbitmq broker now from the DOT NET code i am trying to connect to this broker.
var factory = new ConnectionFactory
{
Uri = new Uri("amqps://it:Password#hostname:5671")
};
var connection = factory.CreateConnection();
I am struggle here to get connection getting below error :
None of the specified endpoints were reachable
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
Update:
It seems your client wants to connect using TLS/SSL (your uri specifies the protocol "amqps" and the port 5671).
Try enabling TLS/SSL:
var factory = new ConnectionFactory {
UserName = userName,
Password = password,
VirtualHost = "/",
HostName = hostName,
Port = port,
Ssl = new SslOption
{ Enabled = true, // <--------
ServerName = hostName }
};
The (JVM based) guide shows how to configure the connection factory. It sets the credentials on the factory, not in the URI:
ConnectionFactory factory = new ConnectionFactory();
factory.setUsername(username); // <----------
factory.setPassword(password); // <----------
//Replace the URL with your information
factory.setHost("b-c8352341-ec91-4a78-ad9c-a43f23d325bb.mq.us-west-2.amazonaws.com");
factory.setPort(5671);
// Allows client to establish a connection over TLS
factory.useSslProtocol()
// Create a connection
Connection conn = factory.newConnection();
(This needs to be translated to the corresponding .NET code)
I am trying to send myself a test email from an AWS Virtual Machine (using an EC2 instance.)
My R code runs great, but I am now trying to send a test email to my email address using sendmailR.
I get the following error message:
Error in socketConnection(host = server, port = port, blocking = TRUE) :
cannot open the connection
In addition: Warning message:
In socketConnection(host = server, port = port, blocking = TRUE) :
localhost:25 cannot be opened
install.packages("sendmailR")
library(sendmailR)
sendmail(from = "XXXX#gmail.com",
to = "YYYY#gmail.com",
subject = "Subject of the email",
body = "Body of the email",
smtp = list(host.name = "smtp.gmail.com", port = 80 , user.name = "XXXX#gmail.com", passwd = "XXXX", ssl = TRUE),
authenticate = TRUE,
send = TRUE)
Does anyone know how this is overcome?
I know REMOTE_ADDR returns the IP Address of the router and not the client user’s machine. HTTP_X_FORWARDED_FOR, since when client user is behind a proxy server his machine’s IP Address the Proxy Server’s IP Address is appended to the client machine’s IP Address. If client machine is behind many proxy server, all server id is appended to it. But I want only client machine address.
How to get that?
string ipaddress;
ipaddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipaddress == "" || ipaddress == null)
ipaddress = Request.ServerVariables["REMOTE_ADDR"];
Will the following code return the ipaddress of client or local machine?
ipaddress = Dns.GetHostName(); // Retrieve the Name of HOST
IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(ipaddress);
IPAddress[] addr = ipEntry.AddressList;
string ip = addr[2].ToString();
or shall I go for this
private string GetUserIP()
{
string ipList = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (!string.IsNullOrEmpty(ipList))
{
return ipList.Split(',')[0];
}
return Request.ServerVariables["REMOTE_ADDR"];
}
to fetch first one?
After upgrade to XCode 8, my iphone with IOS 10 cannot receive push notification any more.
I have enable the "Automatically manage signing".
I re-generate the certificate from Apple website, the universal one.
My local codes is running without any error.
I can get device token correctly with the codes (swift 3):
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
print("start didFinishLaunchingWithOptions")
// Register the supported interaction types.
let types = UIUserNotificationType([.alert, .badge, .sound])
let mySettings = UIUserNotificationSettings(types: types, categories: nil)
UIApplication.shared.registerUserNotificationSettings(mySettings)
// Register for remote notifications.
UIApplication.shared.registerForRemoteNotifications()
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print("start didRegisterForRemoteNotificationsWithDeviceToken")
let deviceTokenString = ((deviceToken as NSData).description.trimmingCharacters(in: CharacterSet(charactersIn: "<>")) as NSString).replacingOccurrences(of: " ", with: "")
....
}
My PHP in server side always return 200 which is successful.
$ch = curl_init();
if (!defined('CURL_HTTP_VERSION_2_0')) {
define('CURL_HTTP_VERSION_2_0', 3);
}
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
$pem_file = '/var/my.pem';
$pem_secret = 'xxxxxx';
$apns_topic = 'xxxxxx';
$apns_expiration = 2;
$change_alert = "{
\"aps\": {
\"alert\": \"$alert_message\",
\"badge\": $badge,
\"sound\": \"default\"
},
\"xxxxxxxx\": \"$xxxxxx\"
}";
$url = "https://api.development.push.apple.com/3/device/$device_token";
//$url = "https://api.push.apple.com/3/device/$device_token";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $change_alert);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("apns-topic: $apns_topic", "apns-expiration: $apns_expiration"));
curl_setopt($ch, CURLOPT_SSLCERT, $pem_file);
//curl_setopt($ch, CURLOPT_SSLCERTPASSWD, $pem_secret);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
My apns-topic is the same with my app bundle id.
Any idea for this issue?
BTW, XCode 8 is not as stable as the previous version.
===============
CURL logs:
* Trying 17.188.135.156...
* Connected to api.push.apple.com (17.188.135.156) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:#STRENGTH
* successfully set certificate verify locations:
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLSv1.2 / ECxxxxxxxxxxxxxxxxxx
* ALPN, server accepted to use h2
* Server certificate:
* subject: CN=api.push.apple.com; OU=management:idms.group.533599; O=Apple Inc.; ST=California; C=US
* start date: Aug 28 19:03:46 2015 GMT
* expire date: Sep 26 19:03:46 2017 GMT
* subjectAltName: host "api.push.apple.com" matched cert's "api.push.apple.com"
* issuer: CN=Apple IST CA 2 - G1; OU=Certification Authority; O=Apple Inc.; C=US
* SSL certificate verify ok.
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
* TCP_NODELAY set
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* Using Stream ID: 1 (easy handle 0x7f2d6eda3970)
> POST /3/device/3xxxxxxxxxxxxxxxxxx HTTP/1.1
Host: api.push.apple.com
Accept: */*
apns-topic: xxxxxxxxxx
apns-expiration: 0
Content-Length: 316
Content-Type: application/x-www-form-urlencoded
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
< HTTP/2.0 200
< apns-id:AF034xxxxxxxxxxxx0F9F27
<
* Connection #0 to host api.push.apple.com left intact
I'm trying to redirect any HTTP requests to my server over to HTTPS.
ELB is listening on port 80 and forwarding all request to port 8088 on my application. The application then sends a 301 Moved Permanently response redirecting to the same URL, but with any ports stripped off and 'https://' prepended. This causes clients to re-request the url over HTTPS.
When I test it locally it works fine, but when I deploy it to EC2 behind an Elastic Load Balancer I get 502 Bad Gateway coming back. The server is receiving the request and appears to be sending the redirect correctly (as I said, it works when I hit the server directly, not via a load balancer).
It turns out that ELB is very picky about what it considers a 'valid' response and will return 502 Bad Gateway if it isn't happy. I fixed it by making sure the response from my server had the following headers:
eg. if I was listening at http://example.com
I send back the following response:
HTTP/1.1 301 Moved Permanently
Content-Type: */*; charset="UTF-8"
Location: https://example.com/
Content-Length: 0
This makes ELB happy and everything works.
For interest, here's the code (Java, using Simpleframework):
private static void startHttpsRedirector() throws IOException {
org.simpleframework.http.core.Container container = new org.simpleframework.http.core.Container() {
#Override
public void handle(Request request, Response response) {
Path path = request.getPath();
Query query = request.getQuery();
String rawHost = request.getValue("host");
System.out.println("Raw host: " + rawHost);
System.out.println("Raw path: " + path);
System.out.println("Raw query: " + query);
String host = rawHost.replaceFirst("\\:.*", "");
response.setStatus(Status.MOVED_PERMANENTLY);
String redirectTo = "https://" + host + path + (query.values().size() > 0 ? "?" + query : "");
System.out.println("redirectTo = " + redirectTo);
response.setContentType("*/*; charset=\"UTF-8\"");
response.setValue("Location", redirectTo);
response.setContentLength(0);
try {
response.commit();
response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
};
Server server = new ContainerServer(container);
Connection connection = new SocketConnection(server);
SocketAddress address = new InetSocketAddress(8088);
connection.connect(address);
}
The same code in javascript can be found here: https://gist.github.com/dhobbs/6164710