Email contact form with success message but no email received

I’m getting a success message but no email received. Tried both locally and on my server.

Do I need to setup a “transport configuration”? https://getkirby.com/docs/guide/emails

try {
  $kirby->email([
    'template' => 'email',
    'from'     => 'MYEMAIL',
    'replyTo'  => $data['email'],
    'to'       => 'MYEMAIL',
    'subject'  => esc($data['name']) . ' sent you a message from your contact form.',
    'data'     => [
      'text'   => esc($data['text']),
      'sender' => esc($data['name'])
    ]
  ]);
}

The problem is often that if you send email from your local server, it never arrives because rejected by the receiving mail server.

I suggest you set up something like Mailhog for development.

But even on my server I don’t receive anything. Do I need to setup anything on that side as well?

I don’t quite understand?

I’ve tried the form on the web, not just locally on my computer. Same result.

Very often, such mail arrives ages later in a bulk. Have you also checked the spam folder?

Are you on a Mac? Then you can try to log what is happening like I suggested here: Kirby Mail - Sending to multiple recipients

However, I suggest you install MailHog or a similar software locally for testing. It has the additional advantage that your IP doesn’t get blocked for sending Spam.

Instead of sending through your own server, you could also try with a mail service.

1 Like

Ah just arrived in the spam folder now. So you suggest using a service like SendGrid to improve deliverability?

Yes, while this is no guarantee, I think it’s a much better option if you want to make sure your mail arrives.

1 Like

I’m having a similar issue, but in reverse.

When I test my email form on my local environment I receive the email instantly but after uploading it to a live environment I don’t receive any emails but get the success message. (I’ve checked my spam and its been two days now). Do I need to set the transport config ?

For reference I’ve followed the structure on the Kirby example

The transport config only needs to be set if you are using SMTP and would then need your SMTP-settings. Maybe you need to configure that for your hosting provider, that might be. The standard way of sending mail would be through PHP mail but that must then be enabled on the server. Check out your hosting providers documentation or contact their support.

Thanks, I’ll check with the hosting provider