i tried to configure SMTP in my Gitlab-Instance (following this guideline). but dont get it working.
gitlab.rb
gitlab_rails['gitlab_email_from'] = "admin#example.com"
gitlab_rails['gitlab_support_email'] = "admin#example.com"
#nginx['redirect_http_to_https'] = false
#nginx['ssl_certificate'] = "/etc/gitlab/ssl/gitlab.crt"
#nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/gitlab.key"
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = 'smtp.exmail.qq.com'
gitlab_rails['smtp_port'] = 25
gitlab_rails['smtp_user_name'] = 'admin#example.com'
gitlab_rails['smtp_password'] = 'has been removed'
gitlab_rails['smtp_domain'] = 'smtp.qq.com'
gitlab_rails['smtp_authentication'] = :plain
gitlab_rails['smtp_enable_starttls_auto'] = true
production.log
Sent mail to i#example.com (8017.5ms)
mail.log
May 9 09:02:14 nday postfix/smtp[27203]: B16EF12019C: to=<i#example.com>, relay=none, delay=1049, delays=1017/0.04/32/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=mxbiz2.qq.com type=AAAA: Host not found, try again)s
May 9 09:02:14 nday postfix/smtp[27202]: 40274120CA7: to=<i#example.com>, relay=none, delay=988, delays=955/0.04/32/0, dsn=4.4.3, status=deferred (Host or domain name not found. Name service error for name=mxbiz2.qq.com type=AAAA: Host not found, try again)
BTW:I have changed the DNS and refresh. mail.log haven't logged my operation. It's old log.
Is your account new on Digital Ocean?
If yes, you need to ask them to unlock sendmail functionality.
This unlock is by account, not by droplet.
You will can use sendmail in all others droplets created by you after this unlock.
Related
I'm trying to make code to send a simple mail via SMTP, I read that I must use the class phpmailer and also install pear engine on the server root, I downloaded some different files to authenticate the SMTP but always requires more files that I don't have or cant be charged. Actually, the PHP errors display this:
Warning: require_once(): open_basedir restriction in effect. File(/opt/plesk/php/7.1/share/pear/PEAR.php) is not within the allowed path(s): (/var/www/vhosts/necotec.es/:/tmp/) in /var/www/vhosts/necotec.es/httpdocs/prueba_smtp/Mail.php on line 48
Warning: require_once(/opt/plesk/php/7.1/share/pear/PEAR.php): failed to open stream: Operation not permitted in /var/www/vhosts/necotec.es/httpdocs/prueba_smtp/Mail.php on line 48
Fatal error: require_once(): Failed opening required 'PEAR.php' (include_path='.:/opt/plesk/php/7.1/share/pear') in /var/www/vhosts/necotec.es/httpdocs/prueba_smtp/Mail.php on line 48
I dont know if cant be found or is a permision problem the files by default takes 644 permisions in this server. Any clue would be helpfull thanks.
open_basedir restriction in effect
error means that some files or scripts are located out of allowed directory.
In your case this file is /opt/plesk/php/7.1/share/pear/PEAR.php.
In Plesk you can disable open_basedir(not secure): Domains > example.com > PHP Settings and set open_basedir to none.
Another way(more secure) is to set open_basedir as {WEBSPACEROOT}{/}{:}{TMP}{/}:/opt/plesk/php/7.1
I was able to configure PHPMailer on my test server(Plesk 17.5-17.8) using steps:
Logged in to the server using SSH
Went to domain Document root directory: # cd /var/www/vhosts/example.com/httpdocs/
Run the command taken from github: # composer require phpmailer/phpmailer
As a result "vendor" folder appeared in "httpdocs" folder.
Created a testmail.php file based on 0-send-email-plesk.php:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
//Load Composer's autoloader
require 'vendor/autoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2; # 0 off, 1 client, 2 client y server
$mail->CharSet = 'UTF-8';
$mail->Host = 'localhost';
$mail->Port = 25;
$mail->SMTPSecure = 'tls'; # SSL is deprecated
$mail->SMTPOptions = array (
'ssl' => array(
'verify_peer' => true,
'verify_depth' => 3,
'allow_self_signed' => true,
'peer_name' => 'Plesk',
)
);
$mail->SMTPAuth = true;
$mail->Username = 'sender#example.com';
$mail->Password = 'password';
$mail->setFrom('sender#example.com', 'Name Surname');
$mail->addAddress('recipient#domain.tld', 'Name Surname');
$mail->Subject = 'Email subject';
$mail->msgHTML('Email content with <strong>html</strong>');
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
It assumes that local mail server is used and Default Plesk self signed certificate is used by mail server: Plesk > Tools & Settings > SSL/TLS Certificates > Certificate for securing mail
I have tried to set up a Zulip server. For now it works but I can not invite anbybody, actually, the smtp server doesn't work.
I use mailgun, here is its configuration:
then for my Zulip configuration, I set up:
/etc/zulip/setting.py
EMAIL_HOST = 'smtp.mailgun.org' EMAIL_HOST_USER =
'postmaster#www2.vt*****'
MAIL_USERNAME = 'testsmtp#www2.vt******'
MAIL_PASSWORD = 'Az******'
SECURITY_EMAIL_SENDER = 'testsmtp#www2.vt******'
EMAIL_USE_TLS = True EMAIL_PORT = 587
/etc/zulip/zulip-secrets.conf
[secrets]
zulip_org_id = 9724f205-ed93-4********
mail_password = 12******
postgres_password = *******
email_password = cw4DKsfuHnJ********* (password for my account postmaster#www2.vt*****)
Even though, when I try the command: /home/zulip/deployments/current/manage.py send_test_email testsmtpsend#laposte.net I get the error:
File "/usr/lib/python3.5/smtplib.py", line 720, in login
initial_response_ok=initial_response_ok)
File "/usr/lib/python3.5/smtplib.py", line 641, in auth
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, b'5.7.0 Mailgun is not loving your login or password')
Someone knows where this error could come from ? It seems my login or password isn't good but I tried every account I had on mailgun, I even tried to create new ones...
I am currently trying to configure my first Postfix - Dovecot - PostgreSQL installation.
When I connect from Thunderbird, I can receive and send mail on my 3 domains with virtual and real mail accounts. Emails are instantaneously sent.
It works too when I use mail (mailutils). But emails need like 1 minute to be sent.
telnet 25 from the server and outside the server send mail correctly too. Emails are instantaneously sent.
However, when I try to send mail from my Gmail or Yahoo mail accounts to this domain, I receive this kind of error :
Gmail
Technical details of temporary failure:
The recipient server did not accept our requests to connect. Learn more at http://support.google.com/mail/bin/answer.py?answer=7720
[(10) mail.domain-1.com. [MY_IP]:25: Connection timed out]
And I don't get any message in /var/log when sending a mail from external domains
Software versions :
LinuxMint : 16 Petra (Debian Wheezy)
Postfix : 2.10.2
Dovecot : 2.1.7
PostgreSQL : 9.1.13
Here is my main.cf :
debug_peer_list = domain-1.com
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
append_dot_mydomain = no
readme_directory = no
transport_maps = pgsql:/etc/postfix/sql/transport.cf
virtual_uid_maps = pgsql:/etc/postfix/sql/uids.cf
virtual_gid_maps = pgsql:/etc/postfix/sql/gids.cf
virtual_alias_maps = pgsql:/etc/postfix/sql/virtual.cf
virtual_mailbox_maps = pgsql:/etc/postfix/sql/mailboxes.cf
virtual_mailbox_base = /var/spool/virtual_mailboxes/
virtual_mailbox_limit = 51200000
mydestination = domain-1.fr domain-2.com domain-3.org localhost.$mydomain localhost
smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks, reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
queue_directory = /var/spool/postfix
Here is my master.cf :
smtp inet n - y - - smtpd
-o smtpd_sasl_auth_enable=yes
-o smtpd_sasl_type=dovecot
-o smtpd_sasl_path=private/auth
There is currently no security like SSL or anti-spam. I just put an SHA512-CRYPT password.
As for my DNS configuration (it must come from here, ... but I don't see anything) :
domain-1.com. 10800 IN MX 10 mail.domain-1.com.
mail.domain-1.com. 10800 IN CNAME www.domain-1.com.
www.domain-1.com. 300 IN A SERVER_IP
I had just put a firewall only allowing mails from me.
Allowing anywhere on port 25 and 143 just made it...
...
I used PHPMailer to send out email and it work perfectly fine on localhost. However, as client requested, we have to upload everything onto webmin. The PostFix Mail Server was being installed for us. The problem is that I could not get the email function to work on the server.
Here are my codes.
<?php
require_once('class.phpmailer.php');
$mail = new PHPMailer();
$body = 'Test Email';
$mail->IsSMTP(); // telling the class to use SMTP
$mail->SMTPDebug = 2; // enables SMTP debug information (for testing)
// 1 = errors and messages
// 2 = messages only
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->Host = "smtp.xxx.xxx.xx";
$mail->Port = 25; // set the SMTP port for the GMAIL server
$mail->Username = "";
$mail->Password = "";
$mail->SMTPSecure = 'tsl';
$mail->SetFrom('support#xxx.xxx', 'Support');
$mail->Subject = "PHPMailer Test Subject via smtp, basic with authentication";
$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; // optional, comment out and test
$mail->MsgHTML($body);
$address = "xxx#hotmail.com";
$mail->AddAddress($address, "Sara Chan");
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
?>
Error message:
SMTP ERROR: Failed to connect to server: Permission denied (13) SMTP connect() failed. Mailer Error: SMTP connect() failed.
I have tried configuring the postfix main.cf file, but it still does not work.
I've tried:
http://postfix.state-of-mind.de/patrick.koetter/smtpauth/postfix_configuration.html
http://www.postfix.org/BASIC_CONFIGURATION_README.html
http://wiki.centos.org/HowTos/postfix
http://www.postfix.org/STANDARD_CONFIGURATION_README.html#null_client
Configuration from these links are different. I'm a new PHP programmer (Still an undergraduate student), and all these are really confusing. Right now, my postfix main.cf is back to its 'default' state. What should I do now?
It looks like you're using an old version of PHPMailer, so update that.
If you're sending from the same server as your script (which it sounds like you are since you're configuring postfix), don't use SMTP, call the IsMail() or IsSendmail() function instead of IsSMTP().
There's no such SMTP secure mode as 'tsl' - you're thinking of 'tls', and if you were going to use that it would probably be on port 587 rather than 25.
You won't need to supply auth credentials if you're sending via mail or sendmail.
I had the same error on a Oracle Linux 7.7 server and solved it by entering the following commands:
sudo setsebool -P httpd_can_sendmail 1
sudo setsebool -P httpd_can_network_connect 1
I'm using lighttpd and pfp-fpm.
All work correctly, but if I call a mysql_connect() on my php scripts I get an empty page.
Like a "denied operation".
This is my php-fpm.conf pool
[example.com]
listen = 127.0.0.1:9001
listen.backlog = -1
user = example.com
group = example.com
pm = dynamic
pm.max_requests = 0
pm.max_children = 2
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
chroot = /home/vhosts/example.com/
request_terminate_timeout = 2
request_slowlog_timeout = 1
slowlog = /home/vhosts/example.com/log/php-slow.log
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
This is my lighttpd vhost:
$HTTP["host"] =~ "(^|.)example\.com$" {
server.document-root = "/home/vhosts/example.com/web"
server.errorlog = "/home/vhosts/example.com/log/error.log"
accesslog.filename = "/home/vhosts/example.com/log/access.log"
fastcgi.server = (
".php" => (
"localhost" => (
"docroot" => "/web",
"host" => "127.0.0.1",
"port" => "9001"
)
)
)
}
What is wrong? If I don't use mysql I can see the result of the php script correctly.
Turning on error display and posting those errors would be helpful, but since you can use mysql without chrooting php, I guess you are getting some connection error, since php tries to connect to mysql on localhost using socket ( php compiled with --with-mysql-sock=/var/mysql.sock), and most likely this socket is outside your chrooted environment.
You can try:
Recompiling php to not use socket
creating hard link to socket in your chrooted path
using some internal ip (like 10.0.0.1,192.168.0.1) instead of loopback
Seems to me all the problems are because of the user and group being example.com
i guess that user doesnt have rights to perform the requested tasks