I'm trying to setup msmtp
Here's my config file
defaults from name#domainname.co.id
account name
host 10.1.1.15
from from name#domainname.co.id
auth off
port 25
account default : name
and here's my log sending email by using php mail() function
https://www.dropbox.com/s/8g7c32atjzsly5j/msmtp-log.txt?dl=0
I can't override the "from" field and it keep using "default"
Can anyone give some advice?
Related
I am trying to send mails via smtp on my website, ( Symfony 5.2 ), but every time I try to use the built-in mailer bundle, I get the error :
Expected response code "250" but got code "530", with message "530 5.7.1 Authentication required".
I've tried sending mails using a php script, with the same smtp configuration, and it works everytime.
In my .env file :
MAILER_DSN=smtp://mail.infomaniak.com:587?encryption=tls&auth_mode=login&username=MY_USER_NAME&password=MY_PASSWORD
Any idea ?
Thanks !
According to this https://symfony.com/doc/current/mailer.html#transport-setup, the mailer dsn format should be.
MAILER_DSN=smtp://user:pass#smtp.example.com:port
And not
MAILER_DSN=smtp://mail.infomaniak.com:587?encryption=tls&auth_mode=login&username=user&password=pass
Notice how the user and password are specified. Might also worth mentioning that you might need to URL encode your password should it contain characters that need such an encoding.
Have you tried the format from the docs?
What I've got
I'm testing postfix on Virtualbox. Initially I had success by passing incoming mail (towards my domain) to a pipe (approach 1 from this answer https://superuser.com/a/1490699 ) and letting outgoing mail send as normal.
Now I've switched my postfix config to use virtual mailbox features (still on Virtualbox) so I can use Mysql to query that the domain and user exists before accepting mail. With config such as:
virtual_transport = myhook:dummy
virtual_mailbox_domains = mysql:/etc/postfix/mysql-virtual-mailbox-domains.cf
virtual_mailbox_maps = mysql:/etc/postfix/mysql-virtual-mailbox-maps.cf
all working well when testing via postmap -q, and I removed my domain from "mydestination" to ensure mail is not transported to local.
The Issue
I've followed a lot of guides
https://www.linode.com/docs/guides/email-with-postfix-dovecot-and-mysql/
https://wiki.gentoo.org/wiki/Complete_Virtual_Mail_Server/Postfix_to_Database
However these guide are made with Dovecot in mind and I wont be using that.
When sending mail via command line to another user that is found within the virtual mailboxes I get the following error
to=<me#laravel8.test>, orig_to=<me>, relay=none, delay=36, delays=36/0.02/0.05/0, dsn=5.4.4, status=bounced (Host or domain name not found. Name service error for name=laravel8.test type=AAAA: Host not found)
This is despite the domain appearing in virtual_mailbox_domains. Changing to ipv4 had no change
I read that this can be due to Postfix not using /etc/hosts (which points laravel8.test to 127.0.0.1) so I added the following lines to main.cf
lmtp_host_lookup = native
smtp_host_lookup = native
But now I get this error:
to=<support#laravel8.test>, relay=none, delay=0, delays=0/0/0/0, dsn=5.4.6, status=bounced (mail for laravel8.test loops back to myself)
Yes, Is that not what I want? I want mail sent to another user to then transport this mail to my pipe as declared in virtual_transport.
No matter what I do I only seem to encounter more issues.
Please help if possible.
Issue seems to be
/etc/postfix/mysql-virtual-mailbox-domains.cf
was
user = root
password =
hosts = 127.0.0.1
dbname = laravel
query = SELECT domain FROM mailbox WHERE domain='%d' LIMIT 1
When it should be
user = root
password =
hosts = 127.0.0.1
dbname = laravel
query = SELECT domain FROM mailbox WHERE domain='%s' LIMIT 1
I got really confused about when and where %s should be used or %d and %u. Here postfix only sends domain to this mysql query so must be whole string as %s
I know that, to use smtp in gitlab 7.1.1, you need the following config; In:
/home/git/gitlab/config/gitlab.yml
edit following line
## Email settings
# Email address used in the "From" field in mails sent by GitLab
email_from: account#your-mail-server.com
and rename this file
/home/git/gitlab/config/initializers/smtp_settings.rb.sample
to
/home/git/gitlab/config/initializers/smtp_settings.rb
and edit following settings:
ActionMailer::Base.smtp_settings = {
address: "email.server.com",
port: 456,
user_name: "smtp",
password: "123456",
domain: "gitlab.company.com",
authentication: :login,
enable_starttls_auto: true
}
and restart GitLab instance.
Is there other points you need to be aware in order to use smtp-based email with GitLab 7.x?
Note that:
config/initializers/smtp_settings.rb has been added to .gitignore only recently (GitLab 7.0+, PR 7062, commit a727d25)
issue 6023 does mention:
Gitlab uses the system configured sendmail to issue emails to users.
The recommended method is to configure your host sendmail so that it properly works and then Gitlab will successfully email as a result.
If configuring sendmail is not desirable, then Gitlab provides smtp_settings.rb which can be used to override default Gitlab email settings.
This uses ruby net::smtp to configure email.
In order to properly configure it one must know the available SMTP AUTH methods allowed by their mail provider. ruby net::smtp supports only three auth schemes: PLAIN, LOGIN, and CRAM MD5.
issue 6845 reminds us:
If you're using SMTP, make sure you change:
config.action_mailer.delivery_method = :sendmail
to
config.action_mailer.delivery_method = :smtp
in the config/environments/production.rb file.
I'm trying to send an email using Ansible, but I can't understand how it works as I don't know how to provide user and password for such service (not specified in the documentation).
Both my machine and the email server are in the same network, but I need to be authenticated in order to send the email.
This is my yml file:
---
- name: Testing email
hosts: localhost
tasks:
- name: Send email
local_action: mail
host=mail.server.com
port=993
subject="Ansible test mail"
body="Testing email"
from=my#email
to="y#email
charset=utf8
And this is the related content of the hosts' file:
[localhost]
localhost ansible_connection=local
Any idea about how should I configure it? Thanks in advance.
Looking at the source code for the mail module ( https://github.com/ansible/ansible/blob/d1effecb2ef073e478c67a7ca39cf56708a66a48/library/notification/mail ) it doesn't look like it supports SMTP authentication.
It shouldn't be too hard to add support for it however. It would require adding the username and password parameters to the module, detecting if they've both been supplied, and if so, calling smtp.login() with those parameters.
In fact, it looks like there's two pull requests to do exactly that at the moment here
https://github.com/ansible/ansible/pull/7213
and here
https://github.com/ansible/ansible/pull/6667
So support will most likely be added in dev soon.
In order to not accidentally send real emails to people outside the company from an integration test server, I'd like to configure postfix to only send emails to addresses like *#somecompany.com and drop all other emails. Is it possible to somehow configure it in /etc/postfix/main.cf and if yes then how?
You can specify like that with the help of /etc/postfix/transport file
You can add the line transport_maps = hash:/etc/postfix/transport in main.cf
Do the steps below
Create a transport - transport1 and Mail sent to user "user#gmail.com" should go through transport1 and all other mail sent should go through default.
First stop dual instances of postfix if any.
Open /etc/postfix/main.cf
and set inet to all.
Add the following to master.cf
transport1 unix - - n - 1 smtp
-o smtp_bind_address= (add a space at 1st)
-o syslog_name=postfix-localroute1 (add a space at 1st)
Add/create the following to /etc/postfix/transport
somecompany.com transport1:
Run postmap after defining the transport file.
postmap /etc/postfix/transport
I have defined a transport above. It means all mail to #somecompany.com will go through you specifed in transport and that ip will not b displayed as it is in maillog. Instead it will be shown as postfix-localroute1
Add the following to main.cf
transport_maps = hash:/etc/postfix/transport
Run:postmap /etc/postfix/transport
Reload postfix:postfix reload