Comments (9)
I haven't used Sendgrid before, so I'm not completely aware what options they offer. If they offer SMTP login using a domain or IP and login details, that can easily be configured straight in php.ini. If it only supports some kind of JSON or XML API, then I would guess applications would specifically need to implement support for Sendgrid. Could you maybe elaborate on that a bit? I can then see what solutions are possible.
from tabby.
Thanks for getting back to me so soon! I wasn't expecting it hahaha
Thank you for prompting me to research this deeper! After looking at their documentation it looks as though you can sign in using SMTP login as outlined here. There's also an alternate PHP example here,.
So, if I understand correctly, I can just supply php.ini with sendgrid's details as per their documentation and that should work? In that case that's much easier than I was expecting hahaha.
I'll also post the php example if that is relevant here if you're interested!
sendgrid's php example code
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases
$email = new \SendGrid\Mail\Mail();
$email->setFrom("[email protected]", "Example User");
$email->setSubject("Sending with SendGrid is Fun");
$email->addTo("[email protected]", "Example User");
$email->addContent("text/plain", "and easy to do anywhere, even with PHP");
$email->addContent(
"text/html", "<strong>and easy to do anywhere, even with PHP</strong>"
);
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
try {
$response = $sendgrid->send($email);
print $response->statusCode() . "\n";
print_r($response->headers());
print $response->body() . "\n";
} catch (Exception $e) {
echo 'Caught exception: '. $e->getMessage() ."\n";
}
from tabby.
Seems like you can indeed chose between using SMTP credentials or implementing their API into the application. In case of Tabby, I didn't really want to figure out all the different APIs for the more popular email services (Google, Microsoft, Sendgrid, Mailgun, Mailjet, Twilio, ...), especially since I don't want to encourage the use of external and/or closed source solutions but try to adhere to the selfhosted concept of https://github.com/awesome-selfhosted/awesome-selfhosted/ .
Luckily, it seems Sindgrid offers SMTP credentials you can configure in php.ini for all your PHP applications, which is much cleaner and simpler, and very similar to the setup I use (but I use a local email server).
Hopefully you can get things working that way. If you get it set up perfectly, please let me know (and feel free to close the issue at that point). I might clarify further in a next release that you can configure SMTP credentials easily through php.ini, since I don't mention that in the message you quoted.
from tabby.
Great! I'll try to get it set up soon and let you know if it works!
Also if you don't mind, could you share what kind of email server you use? I may try my hand at running my own eventually and only just started looking into different software and docker images.
from tabby.
Oh I think I have it almost finished, but I ran into the following error when actually trying to send the email out:
[20-Sep-2021 06:25:11] WARNING: [pool www] child 72 said into stderr: "sh: 1: /usr/sbin/sendmail: not found"
I realized I hadn't installed sendmail, so I ran apt-get to install it, but it's still running into the same error. Is there some value in pbp.ini that I'm missing that needs to be set?
from tabby.
Okay some updates
My issues with sendmail in the above comments was because I was running tabby in docker as per the instructions found here, since I prefer to run things in docker where possible. However sendmail wasn't included in this configuration, so I had to connect to the docker container and running apt-get install sendmail
which has almost got it working.
Now I'm running into this error:
[SYSLOG] sendmail[1185]: 18KJbEp4001185: [email protected], ctladdr=application (1000/1000), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30465, relay=[127.0.0.1] [127.0.0.1], dsn=4.0.0, stat=Deferred: Connection refused by [127.0.0.1]
I modified the docker launch command like so:
sudo docker run --link some-weird-mariadb -v /tmp/tabby2/:/app -p 8070:80 -p 587:587 webdevops/php-nginx
And no dice. As this is im sure far beyond the intended setup, I will abandon using docker and try with a standard nginx host configuration and update once i get something working.
from tabby.
OKAY FINALLY GOT IT WORKING WITH SENDGRID
I followed these instructions using the sendgrid credentials. Just in case the guide ever falls or someone needs exact instructions here's how I did it
using sendgrid with sendmail
Requirements: Sendgrid and a sendmail account with a verified domain name.First install sendmail if you haven't already. I used sudo apt-get install sendmail
on debian
Change the hostname if you'd like using /etc/hosts but it's not needed.
Run the following commands:
sudo mkdir /etc/mail/authinfo
sudo chmod -R 700 /etc/mail/authinfo
cd /etc/mail/authinfo
sudo nano smtp-auth
now paste the following, replacing actual-api-key
with the api key you got from sendgrid
AuthInfo: "U:root" "I:apikey" "P:actual-api-key"
Next run this command:
sudo makemap hash smtp-auth < smtp-auth
Now to edit the sendmail.mc
cd /etc/mail
sudo nano sendmail.mc
paste this right below the MAILER_DEFINITIONS
define(`SMART_HOST',`[smtp-host]')dnl
define(`RELAY_MAILER_ARGS', `TCP $h 587')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 587')dnl
define(`confAUTH_OPTIONS', `A p')dnl
TRUST_AUTH_MECH(`EXTERNAL DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
define(`confAUTH_MECHANISMS', `EXTERNAL GSSAPI DIGEST-MD5 CRAM-MD5 LOGIN PLAIN')dnl
FEATURE(`authinfo',`hash -o /etc/mail/authinfo/smtp-auth.db')dnl
Then run make
and restart sendmail with sudo /etc/init.d/sendmail restart
Assuming you're using nginx, edit the following file, replacing $VERSION with yoiur actual php version
sudo nano /etc/php/$VERSION/fpm/php.ini
Restart nginx and php
sudo service php$VERSION-fpm restart
And that should be it! Feel free to @ me if anyone has any questions.
from tabby.
Seems you have been busy! Sorry for the late reply, I had a crazy day at work and some stuff I still had to do around the house.
Hmmm, if I understand things correctly, you are now using sendmail with the sendgrid SMTP instead of using the sendgrid SMTP directly in PHP. That's also possible, but a lot more complicated I think. But I'm glad you got it working! :D
To answer your earlier question: I run postfix with a MySQL backend to define mailboxes and aliases, I use dovecot as the LDA (so I can use sieve and managesieve) and for IMAP, and use amavis with spamassassin for anti-spam. It's not a complicated setup, but it can be challenging to start to understand the components.
from tabby.
No problem!! and yeah, I switched to SMTP + sendmail because apparently php on linux systems doesn't support SMTP?? at least without installing and configuring something else. This way ended up being easier.
I saw postfix come up repeatedly on my searches! I'll def look into it sometime, maybe even try a mail server docker out now that I know how to get sendgrid working with SMTP credentials. It sounds challenging but thanks for telling me anyways! It'll be good to have something to launch off of!
from tabby.
Related Issues (20)
- Alias support
- Recurring expenses? HOT 3
- In the US, we donβt have IBAN HOT 4
- Docker installation HOT 3
- Adding negative debt (credit) through an activity fails
- Unable to delete activity HOT 11
- Feature Request: EPC QR-codes for bank transfer to European IBAN number
- Cannot start session when headers already sent HOT 5
- Feature Request: Support for South African currency and bank account types HOT 6
- Feature Request Docker container HOT 14
- Switch from default mail function to PHPMailer HOT 5
- Issue: Typo in `check_any_debtors` function causing potential bug
- Today button when creating activity
- Also mention the total amount due in notification mails of new events
- Add favicon
- Change sorting for people with no debt
- Any chance for LDAP auth and SSO? HOT 11
- Debt values >1,000.00 not shown properly in record HOT 3
- 404 after install HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tabby.