Giter Site home page Giter Site logo

Use External SMTP Relays about postal HOT 27 CLOSED

postalserver avatar postalserver commented on August 15, 2024 12
Use External SMTP Relays

from postal.

Comments (27)

adamcooke avatar adamcooke commented on August 15, 2024 5

That isn't supported. You should configure your relay to allow connections from the IP of your Postal server.

from postal.

adamcooke avatar adamcooke commented on August 15, 2024 3

I have added support for relaying outgoing SMTP through external hosts (except in the case when an incoming e-mail is forwarded to another SMTP server). By doing this, however, you will lose some functionality from Postal (including the suppression list).

To configure SMTP relay hosts you can add the following to your config file:

smtp_relays:
  -
    hostname: othersmtp.yourdomain.com
    port: 25
    ssl_mode: Auto

ssl_mode can be None, Auto, STARTTLS or TLS. Same as the options available when configuring an SMTP endpoint for incoming e-mail.

You can add as many relays as you want. They will be tried in order until accepted.

Please give this a go and let me know how you get on.

from postal.

windware-ono avatar windware-ono commented on August 15, 2024 3

I really wanted to have SMTP auth as I was relaying emails to an external email delivery service such as SendGrid when IP reputation can't be fixed by a private effort.

So, in my structure, Postfix accepts emails from email clients, postfix relays toward Postal and then Postal should be relaying to SendGrid.

It turned out to be the SMTP auth implementation is quite simple to do that and I just modified 4 lines to accomplish it.

Within postal-worker-1 container, this is the diff for /opt/postal/app/lib/postal/smtp_sender.rb

66c66
<             smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname)
---
>             smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname, server[:user], server[:password])
261c261,263
<             :ssl_mode => relay.ssl_mode
---
>             :ssl_mode => relay.ssl_mode,
>             :user => relay.user,
>             :password => relay.password

which I mounted with,

- /opt/postal/smtp_sender.rb:/opt/postal/app/lib/postal/smtp_sender.rb

in the docker-compose volumes section and just placed the modified version at /opt/postal/smtp_sender.rb on the host and done docker restart postal-worker-1.

You can place your SMTP auth parameters in the postal.yml in the smtp_relays section by adding user and password, which would look like this for SendGrid,

smtp_relays:
  -
    hostname: smtp.sendgrid.net
    port: 587
    ssl_mode: Auto
    user: apikey
    password: YOUR-API-KEY

Hope someone with more insight into the code base review it and add it in an official release.

from postal.

mr119 avatar mr119 commented on August 15, 2024 2

What about authentication on SMTP relays?

from postal.

jduncanator avatar jduncanator commented on August 15, 2024 2

You'll need to be more specific than "kind of" if you are looking for any valuable advice.

Postal does not support this out of the box, so the best bet is to augment it with a local mail relay. The general idea is to setup a local SMTP relay that accepts mail (without authentication) on 127.0.0.1. Configure Postal to use this SMTP relay. Then, in the local SMTP relay, configure it to relay mail to your external SMTP relay that requires authentication, and configure your authentication in there.

Note: With this setup, you'll lose almost all visibility into sending statistics, as the local mail relay will queue, drop and manage the email separate from Postal.

Using postfix as an example, you can configure a relayhost (and proper access control) in your main.cf. For example:

relayhost = [smtp.sendgrid.net]:587

# Only allow relaying mail from the local machine
mynetworks = 127.0.0.0/8, [::1]/128
smtpd_recipient_restrictions = permit_mynetworks, reject_unauth_destination

Then, you can configure a SASL authentication file that holds the username and password for your SMTP relay:

smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous

Your /etc/postfix/sasl_passwd file would look something like:

[smtp.sendgrid.net]:587 username:password

Of course this all depends on your installation and requirements, and one would hope that if you were going down this path, you knew what you were doing and would know what all of the mentioned configuration options do. The last thing we need is another open mail relay on the internet! 😄

from postal.

willpower232 avatar willpower232 commented on August 15, 2024 1

@karankashyap208 each endpoints page has a short description of what it does if you haven't added any entries, routes connect incoming email messages to the endpoints. It sounds like you need an address endpoint for domain2.com. Please open a new issue if you are stuck rather than commenting on old issues.

from postal.

brainiers avatar brainiers commented on August 15, 2024

Hello We arrying to relay outbound emails from Postal to another server. The main reason is that with postal we cannot manage the VMTAs like we can with PowerMTA. We have tried the code below:

smtp_relays:
hostname: othersmtp.yourdomain.com
port: 25
ssl_mode: Auto
We have tried to configure 10 SMTP relays but none is working. We have disabled username and password. The SMTP for POstal Emails is working perfectly.

HOw can we achieve this?

from postal.

Manishjodhani avatar Manishjodhani commented on August 15, 2024

@brainiers did you find any things about SMTP relays authentication

from postal.

jduncanator avatar jduncanator commented on August 15, 2024

@Manishjodhani You should be using whitelists for your authentication. Allow your SMTP relay to accept mail unauthenticated from your Postal server's IP address.

If you are trying to relay email via Gmail (or other consumer mail relays that require authentication), I would highly recommend you seek an alternative. They are not designed to be used for this use case, and you'll most likely get your account throttled or banned.

If you really MUST have authentication to an external SMTP relay (eg. SendGrid or another platform designed for delivering transactional/bulk email) then you can setup a local mail relay without authentication on your Postal server (something like sendmail), and then configure it to relay mail via your external mail relay with authentication. I have configured a Postal install with this setup, and it works surprisingly well, albeit with higher maintenance.

from postal.

Manishjodhani avatar Manishjodhani commented on August 15, 2024

"then configure it to relay mail via your external mail relay with authentication." what do you mean by this...???
I use as smtp relays like postfix or pmta. In config file there is no define of authentication.
Is there any method to get authentication by programming in postal..that's it.... i really want to know yes or no ??

from postal.

jduncanator avatar jduncanator commented on August 15, 2024

I'm not sure what question you are asking anymore. Are you trying to authenticate with an external mail relay?

from postal.

Manishjodhani avatar Manishjodhani commented on August 15, 2024

Yes....kind of

from postal.

Manishjodhani avatar Manishjodhani commented on August 15, 2024

Thanks for this
I will try this on postfix.
And but in pmta there is no SASL Authentication.So what about in Pmta ???

from postal.

jduncanator avatar jduncanator commented on August 15, 2024

I don't use PMTA so I can't help you there, I'd recommend you look into their documentation on how to authenticate with mail relays. It looks like this SO answer has the correct configuration syntax, but I'm not sure how correct or applicable this is as I've never used PMTA before.

from postal.

Manishjodhani avatar Manishjodhani commented on August 15, 2024

Thanks @jduncanator
You were telling this pmta >> external smtp
but i want to do this postal >>external smtp (PMTA)
??

from postal.

rsgehlot avatar rsgehlot commented on August 15, 2024

How will the bounce data reflect in the postal dashboard?

from postal.

jduncanator avatar jduncanator commented on August 15, 2024

@rsgehlot From my understanding, bounce data depends on the Return-Path header of the email. So long as the Return-Path email address is setup (and you have setup incoming email for Postal) the bounce data should still get tracked correctly when using an external SMTP relay.

from postal.

imanudin11 avatar imanudin11 commented on August 15, 2024

Hello,

Sorry to open again this issue. Is it possible to relay over API on POSTAL? My topology like below :

Postal -> Relay to External server using API -> My Server Application

On my server application (like newsletter server/mail campaign), we have some information like :

  • email open
  • email sent
  • email click link
  • email bouncing
  • Graphic
  • Client access to check report

My goal is to records all email that sent from client to my application server. Maybe the topology like below :

Email server on my client -> Relay to Postal using Auth -> Postal relay to my application using API -> My application records all email that sent from Postal

from postal.

jduncanator avatar jduncanator commented on August 15, 2024

@imanudin11 You shouldn't need to relay mail into your application. You should be able to access the appropriate information from your application via the Postal API.

If the Postal API doesn't expose enough of the information you'd like, then I'd recommend opening a feature request for those features to be added to Postal.

Alternatively, you could implement an SMTP server in your application that listens on the SMTP port, and then set Postal up to relay email there.

As a comment on your initial request, I don't think it is inside the scope of Postal to support arbitrary external application APIs, as your API is likely different from the next persons, who is different from the next persons. Perhaps this could be resolved by some sort of Webhook functionality being added to Postal, that allows specific information about certain events in Postal being POSTed to an external application by means of a web request? That said, this is the topic for another issue...

from postal.

imanudin11 avatar imanudin11 commented on August 15, 2024

Hello @jduncanator ,

Thanks for your information and advice. I've tried to install SMTP on my application server. But, every email that sent from the SMTP, not recorded on my application. Such as from, subject, to and etc.

I need a feature like Postal. That have SMTP and all email transaction recorded on the web application.

I see Postal have own SMTP server. Not Postfix or Sendmail that familiar to me :)

from postal.

willpower232 avatar willpower232 commented on August 15, 2024

Postal can either send email for a domain that is configured to anywhere or receive email for a domain that is configured from anywhere but I'm not sure if that fits your requirements exactly.

Have a look at the Routes tab in your Postal and if you have any more questions, please open a new issue.

from postal.

karankashyap208 avatar karankashyap208 commented on August 15, 2024

Postal can either send email for a domain that is configured to anywhere or receive email for a domain that is configured from anywhere but I'm not sure if that fits your requirements exactly.

Have a look at the Routes tab in your Postal and if you have any more questions, please open a new issue.

Hy will,
I want to know how i can set routes in my postal mail server. I want all incoming emails on that server to another domain email.
Like i am using domain1.com for sending email and domain1.com is linked with postal in domain DNS.
I want to receive replies of all emails from that domain1.com sending using postal mail server on domain2.com mail server that is on godaddy shared server.
How i can route incoming email to domain2.com emails ???

What entires I need to exactly put in Routes and what are for SMTP Endpoints ??

and please share the solution with the real values that i need to put in the route and SMTP endpoints sections.

As i tried almost everything in this and still receiving of emails if not working.

Thanks in advance for this.

from postal.

jpvaillancourt avatar jpvaillancourt commented on August 15, 2024

@windware-ono Thank you so much! Hope this could be added to the original repo.

from postal.

Weijtmans avatar Weijtmans commented on August 15, 2024

I really wanted to have SMTP auth as I was relaying emails to an external email delivery service such as SendGrid when IP reputation can't be fixed by a private effort.

So, in my structure, Postfix accepts emails from email clients, postfix relays toward Postal and then Postal should be relaying to SendGrid.

It turned out to be the SMTP auth implementation is quite simple to do that and I just modified 4 lines to accomplish it.

Within postal-worker-1 container, this is the diff for /opt/postal/app/lib/postal/smtp_sender.rb

66c66
<             smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname)
---
>             smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname, server[:user], server[:password])
261c261,263
<             :ssl_mode => relay.ssl_mode
---
>             :ssl_mode => relay.ssl_mode,
>             :user => relay.user,
>             :password => relay.password

which I mounted with,

- /opt/postal/smtp_sender.rb:/opt/postal/app/lib/postal/smtp_sender.rb

in the docker-compose volumes section and just placed the modified version at /opt/postal/smtp_sender.rb on the host and done docker restart postal-worker-1.

You can place your SMTP auth parameters in the postal.yml in the smtp_relays section by adding user and password, which would look like this for SendGrid,

smtp_relays:
  -
    hostname: smtp.sendgrid.net
    port: 587
    ssl_mode: Auto
    user: apikey
    password: YOUR-API-KEY

Hope someone with more insight into the code base review it and add it in an official release.

This works like a charm! Why don't you submit a pull request?

from postal.

engrpeters avatar engrpeters commented on August 15, 2024

I really wanted to have SMTP auth as I was relaying emails to an external email delivery service such as SendGrid when IP reputation can't be fixed by a private effort.
So, in my structure, Postfix accepts emails from email clients, postfix relays toward Postal and then Postal should be relaying to SendGrid.
It turned out to be the SMTP auth implementation is quite simple to do that and I just modified 4 lines to accomplish it.
Within postal-worker-1 container, this is the diff for /opt/postal/app/lib/postal/smtp_sender.rb

66c66
<             smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname)
---
>             smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname, server[:user], server[:password])
261c261,263
<             :ssl_mode => relay.ssl_mode
---
>             :ssl_mode => relay.ssl_mode,
>             :user => relay.user,
>             :password => relay.password

which I mounted with,
- /opt/postal/smtp_sender.rb:/opt/postal/app/lib/postal/smtp_sender.rb
in the docker-compose volumes section and just placed the modified version at /opt/postal/smtp_sender.rb on the host and done docker restart postal-worker-1.
You can place your SMTP auth parameters in the postal.yml in the smtp_relays section by adding user and password, which would look like this for SendGrid,

smtp_relays:
  -
    hostname: smtp.sendgrid.net
    port: 587
    ssl_mode: Auto
    user: apikey
    password: YOUR-API-KEY

Hope someone with more insight into the code base review it and add it in an official release.

This works like a charm! Why don't you submit a pull request?

How do I achieve this what docker command do I need to run , I was able to get into the interactive terminal of the worker , but changes I make don't persist when I exit . I guess it has to do with mount, how do I achieve this please ?

from postal.

marc5feb avatar marc5feb commented on August 15, 2024

I really wanted to have SMTP auth as I was relaying emails to an external email delivery service such as SendGrid when IP reputation can't be fixed by a private effort.

So, in my structure, Postfix accepts emails from email clients, postfix relays toward Postal and then Postal should be relaying to SendGrid.

It turned out to be the SMTP auth implementation is quite simple to do that and I just modified 4 lines to accomplish it.

Within postal-worker-1 container, this is the diff for /opt/postal/app/lib/postal/smtp_sender.rb

66c66
<             smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname)
---
>             smtp_client.start(@source_ip_address ? @source_ip_address.hostname : self.class.default_helo_hostname, server[:user], server[:password])
261c261,263
<             :ssl_mode => relay.ssl_mode
---
>             :ssl_mode => relay.ssl_mode,
>             :user => relay.user,
>             :password => relay.password

which I mounted with,

- /opt/postal/smtp_sender.rb:/opt/postal/app/lib/postal/smtp_sender.rb

in the docker-compose volumes section and just placed the modified version at /opt/postal/smtp_sender.rb on the host and done docker restart postal-worker-1.

You can place your SMTP auth parameters in the postal.yml in the smtp_relays section by adding user and password, which would look like this for SendGrid,

smtp_relays:
  -
    hostname: smtp.sendgrid.net
    port: 587
    ssl_mode: Auto
    user: apikey
    password: YOUR-API-KEY

Hope someone with more insight into the code base review it and add it in an official release.

Hy, with some minor adjustments i have it working in the latest version of postal.

the edit around line 66 is unchanged. But i did make a change on the second part as shown below.

      hostname: relay.hostname,
      port: relay.port,
      ssl_mode: relay.ssl_mode,
      user: relay.user,
      password: relay.password

super thanks for the info!

from postal.

davidpiccinini avatar davidpiccinini commented on August 15, 2024

Compatibility lost due new Postal v3.x upgrades. In v3.3 not works

from postal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.