4

I'm building my first Craft 3 site, and having problems getting email to send. I've set it to use Sendmail but when I click the Test button in the CP, I get "There was an error testing your email settings".

I know Sendmail isn't the best option but I need something for now until we get something more robust in place. My client doesn't yet have any email set up for this domain, but I assume Sendmail should still be able to create email?

I've tried using Sendmail from the command line and that seems to work fine. For each attempt to test from the control panel, I get this error in web.log:

2018-08-20 10:02:55 [86.167.235.31][1][-][error][application] Error sending email: Expected response code 220 but got code "", with message ""

I'm on Craft 3.0.19. Any ideas what might be going wrong?

2

Most servers (speaking in generalities) won't send mail by themselves anymore. You'll need to use some sort of SMTP service.

Check out SendGrid to get you going. I believe they have a free plan. You can choose SMTP from the mail options from the settings page.

Choose 'Use Authentication' and from there your username is well, your username and your password is...your password. Use Port 587.

Hope this helps!

| improve this answer | |
  • Thanks Damon, I'll check that out. The 100 email/day you get for free might even do the job for this one. Do you have experience of using Sendgrid for an email address that's hosted at Google Mail? I know that using SMTP from a server doesn't play very well with Google Mail, and you need to "allow less secure apps" etc. But I wonder if Sendgrid has a more reliable way round all that? – Frank Harrison Aug 30 '18 at 19:10
  • I've used SendGrid for quite a few projects and haven't had a problem with deliverability. When I did, it was usually my fault. :) – Damon Aug 31 '18 at 2:35
  • Where do you get this from "Most servers (speaking in generalities) won't send mail by themselves anymore." -> I have many servers, different providers, they all send email using PHP fine. I have never ever come across a server that for some reason wont send email using PHP. So not sure what this means. I agree use SMTP, but I find this an curious comment to make. The server i have now can send email fine, but I get this error above, so am looking for a fix to the issue, and not use SMTP. I have another issue with Craft and SMTP I need to see if PHP/Sendmail fixes. – Laurence Cope Sep 23 '19 at 12:30
  • Hi Laurence - thanks for the feedback. When you say, you have many servers from may providers who are they I'm generally curious. What I was trying to say is using the default php mail($to, $from) I've found generally doesn't work. I have had to use a mail provider such as SendGrid or MailGun – Damon Sep 24 '19 at 15:00
1

Where do you get this from "Most servers (speaking in generalities) won't send mail by themselves anymore." -> I have many servers, different providers, they all send email using PHP fine. I have never ever come across a server that for some reason wont send email using PHP. So not sure what this means. I agree use SMTP, but I find this an curious comment to make. The server i have now can send email fine, but I get this error above, so am looking for a fix to the issue, and not use SMTP. I have another issue with Craft and SMTP I need to see if PHP/Sendmail fixes.

I agree. Tough a SMTP Service most of the time IS the better choice, I have projects that simply don't need the Involvement of yet another service. If you happen to have a lot of small clients, that need Craft to send Password Reset Mails and maybe a Contact Form – I go for Sendmail. While this answer is (eventaually) not the solution to the Error of this question, I want to help people that come along here and want to get their Sendmail to work.

Here's some things that might help you to get Sendmail working on your Hosting Provider.

  • On shared hosting platforms you might want to make sure, that the E-Mail – you use as sender – exists in the Hosting Package (I have one Hoster that does that)
  • Make sure the sendmail path is correct (search for it in the Webspace) – it might not always be /usr/sbin/sendmail)
  • Experiment with the sendmail command. A setup that works with most Hosting Providers is /usr/sbin/sendmail -t -f mail@domain.de, where you replace mail@domain.de with the actual address you're sending from (additionally to the sender Address in the Craft Backend.
  • Read the Documentation of your Hosting Provider, oftentimes they tell you what flags need to be present for it to work.

Hope that helps.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.