V9: anyone tested email service yet?

@andrew , I’ve just removed everything and simply pasted 3 strings:

Screenshot_20211118_011520

and here’s the log:

Screenshot_20211118_011543

As you can see:

  • the To is ok
  • the From is NOT, it doesn’t have the email and the same in the headers

AND I did not receive any email.

As you can see in my 3rd post above, if you pass a string to the ‘from’ method, it won’t work because $fromStr = $this->generateEmailStrings([$this->from]); works only on an array of arrays, not on a simple array which is passed to it from the ‘from’ method.

I’ve just tried the Email Test in the Settings - I have not received any email!

Maybe the To field is in form "Name" <address>, but the way concrete displays it strips the stuff between angular parenthesis.
To be sure about that, you can check the value stored in the logs table

No, if I do that, it throws an error:

Exception Occurred: /srv/www/htdocs/c9/concrete/vendor/laminas/laminas-mail/src/Address.php:72 The input is not a valid email address. Use the basic format local-part@hostname (0)

BTW, I’m using Default PHP Mail Function, not SMTP

I also see that some sort of template is used. I don’t create any, it’s coming from the system. Can that be the problem?

The from field is set by the from method:

public function from($email, $name = null)
{
    $this->from = [$email, $name];
}

So, the value of the $this->from field is an array, and [$this->from] is an array of arrays

How’s this

$this->from = [$email, $name]

an array of array? This one is

$this->from[] = [$email, $name]

$this->from is an array, and [$this->from] is an array of arrays

yes, you’re right, didn’t notice the brackets. But it doesn’t work anyway.

It DOES work!

Let’s make an example:

If we call:

$mailService->from('john@doe.com', 'John');

With the above code, the value of $mailService->from is

['john@doe.com', 'John']

So, when we call

$fromStr = $this->generateEmailStrings([$this->from]);

It’s like writing

$fromStr = $this->generateEmailStrings([['john@doe.com', 'John']]);
1 Like

Sorry, I meant the email doesn’t work. I’ve just tried the test and it doesn’t do anything.

Did you test it via the dashboard/system/mail/method/test dashboard page?

Yes, just done it a number of times with different emails.

If I remove the name string from the ‘from’, i.e. $mh->from(‘email@gmail.com’); then at least the header has the email address. Could that be an error with the providers that if there’s no from address they think it’s spam and simply delete it right away?

As I wrote above, you may not see the email address in the Logs dashboard page if you use both the name and the email address.
As I wrote above, if the To header has this value:

To: John <john@doe.com>

When you view the log entry, the part between < and > may be hidden, but it’s still there (it’s simply not displayed in the Logs page).
That’s why you should check directly in the Logs database table.

And does concrete say that the email has been sent?

Of course, otherwise I would have said I got an error

In the SMTP dashboard page (dashboard/system/mail/method), do you have configured to use the Default PHP Mail Function, or an External SMTP Server?

Default PHP Mail Function

If you use the mail() PHP function, Concrete doesn’t have a way to see if the email has been sent by it.
If you want to use mail(), you have to configure a mail sending service in your web server (google for sendmail ).
People usually use an external SMTP service, which is much easier to be configured.

I’ve changed it to SMTP and now it all works fine. :hot_face: :hot_face: :hot_face:

I didn’t want to use it because it’s very slow. Well, it’s either 5-10 sec to send an email or nothing (this is for testing, so it’s ok)

There’s not alternative: you have to use an external SMTP service, or you have to configure PHP and sendmail on your web server.
BTW, 5-10 secs is very slow, you should consider other SMTP services (sadly it’s very hard to find a free SMTP service provider).