SMTP "fsockopen(): php_network_getaddresses: getaddrinfo failed: No such host is known." Error

I apologize for yet another SMTP server issue. I have scoured the forums and reviewed the tutorials, but nothing has helped get the SMTP server working for me.

I am attempting to use SendGrid to send mail based on form info. Originally I had this working on another page and then I broke something. I decided to start fresh and I’m getting an error I wasn’t before. Here are some screenshots of my settings:

For the setup mailer:

For the send mail:

For the form:

Using the debug tutorial I was able to grab the following error:
{“code”:0,“file”:“C:\wamp64\www\crud\dmxConnectLib\lib\mail\Smtp.php”,“line”:100,“message”:“fsockopen(): php_network_getaddresses: getaddrinfo failed: No such host is known. “,“trace”:”#0 [internal function]: exception_error_handler(2, ‘fsockopen(): ph…’, ‘C:\\wamp64\\www\\c…’, 100, Array)\n#1 C:\wamp64\www\crud\dmxConnectLib\lib\mail\Smtp.php(100): fsockopen(‘ssl://smtp.send…’, 465, 0, ‘php_network_get…’, 5)\n#2 C:\wamp64\www\crud\dmxConnectLib\lib\mail\HtmlMimeMail.php(718): lib\mail\Smtp->connect()\n#3 C:\wamp64\www\crud\dmxConnectLib\lib\mail\Mailer.php(114): lib\mail\HtmlMimeMail->send(Array, ‘smtp’)\n#4 C:\wamp64\www\crud\dmxConnectLib\modules\mail.php(64): lib\mail\Mailer->send(Object(stdClass))\n#5 C:\wamp64\www\crud\dmxConnectLib\lib\App.php(173): modules\mail->send(Object(stdClass), ‘’)\n#6 C:\wamp64\www\crud\dmxConnectLib\lib\App.php(137): lib\App->execSteps(Object(stdClass))\n#7 C:\wamp64\www\crud\dmxConnectLib\lib\App.php(107): lib\App->execSteps(Array)\n#8 C:\wamp64\www\crud\dmxConnectLib\lib\App.php(72): lib\App->exec(Object(stdClass))\n#9 C:\wamp64\www\crud\dmxConnect\api\emails\testEmail.php(8): lib\App->define(Object(stdClass))\n#10 {main}”}

This leads me to believe that the local WAMP server isn’t set up properly? But I’m kind of at my wit’s end staring at this. Any guidance would be very much appreciated!

son of a *****… I took a look at the .php script and there was a trailing space in the code. But I couldn’t see that in the properties section of the setup mailer. Will test it out again and see if that fixes everything.

Ok, so that fixed part of the problem.

Now I’m getting what I was seeing before. I get a 200 response from the form, but not seeing an email or any activity show up in SendGrid. I realize this likely isn’t a Wappler issue at all as it has obviously connected to the smtp server and passed the form to it. But if anyone has run into this issue before I would be very curious as to how you solved it!

If anyone comes across this the solution that came up is that 3rd party SMTP services/api’s (SendGrid, and Amazon SES) need to have the email coming FROM a verified sender. So for a contact form, one would not be able to set the FROM address to the form field.

This likely means you will want the to and from address to be the same with the email body containing the name, email, and message.

For example:

To: jane.doe@company.com
From: jane.doe@company.com
Message: “Name: {{$_POST.name}} \n Email: {{$_POST.email}} \n Message: {{$_POST.message}}”