Contact Form with SMTP

On the forum I read: “Check with your server provider to make sure you can post forms on your server that are not processed with SMTP.
Does your server support none SMTP form posting? Blocs doesn’t support form posting over SMTP.”

Is there a way to send a form with SMTP (without coding)?
My provider does not support none SMTP form posting…

Thanks!

You might have luck there just putting your email address. I always put in the account username @ the server name and it works 100% of the time with cpanel. You should have those details from when you created the hosting account. No coding is required if you choose self hosted in the side panel settings.

you mean in the “From” field?

Yes you put that in the from field.

I wil try it…

Thanks!

unfortunately this does not work…

any other suggestions?

Just select self hosted, then contact your web host and ask them what to put in the from field.

You will probably need a self hosted script to do the processing for you. If you get hold of a copy of tectite formmail you can configure the script using a plain text editor. In the configuration settings part of the script (About line 671), you will find a “pear” section - it looks like this.

$PEAR_SMTP_HOST = “mail.yourserver.co”;
$PEAR_SMTP_PORT = 25;
$PEAR_SMTP_USER = “youremail@yourserver.co”;
$PEAR_SMTP_PWD = “xyzabc1234”;

This will tell the script to use your SMTP host to send responses instead of the normal sendmail function. You will have to contact your host to get the correct settings. This setting is usually only required if your host does not allow sending email to addresses outside of the hosted domain.

Once this is done, you would upload your script to a directory on your server. In Blocs, you would choose the custom option for the form settings and enter the url of your script file. When a form is submitted, the data will be sent to the script on your server for processing instead of a script that blocs would otherwise create for you.

There are many other settings in the Tectite formmail script that can help you defeat spam, create a database of contacts, redirect after successful or failed submissions, have plain text or formatted templates for form results etc. For a full list of options, I suggest you visit the tectite website for further information. Many of the options will require hidden fields on your blocs form. These can be added as standard text fields with custom attributes set. The custom attributes will comprise of a field name and a value. Once the attributes are set, the fields will be set as hidden so they don’t show up in your web page.

Thanks.

What is Tectite formmail? where can I find it?

I found tectite formmail on the web and downloaded it

I also found the section on line 671…

I will give it a try

what is with the fields of my form (name, email, message e.g.) are they automatically recognised ?

Thanks! Andreas.

All your form fields will be recognised. Just remember to add the hidden fields as required by the script. These won’t be seen, but will be needed to make the script do what you want it to do.

Hi @Kretschmeier,

this is what we have used for forms as external script and it worked. But we have moved to CRM Pardot now.

<?php	
	// error_reporting(E_ALL); 
	require './dmail/PHPMailer.php';
	require './dmail/Exception.php';
	require './dmail/SMTP.php';
	use PHPMailer\PHPMailer\PHPMailer;
	// date_default_timezone_set('Etc/UTC');
	// require '../vendor/autoload.php';

	$name = $_POST['name'];
	$e_mail = $_POST['e_mail'];
	$phone = $_POST['phone'];
	$company = $_POST['company'];
	$message = $_POST['message'];
	
    if(!isset($_POST['name']) ||
	!isset($_POST['e_mail']) ||
	!isset($_POST['phone']) ||
	!isset($_POST['company']) ||
	!isset($_POST['message'])) {
		echo "Please fill all fields";
		http_response_code(500);
		die();
	}


    if($_POST['name'] == "" ||
	$_POST['e_mail'] == "" ||
	$_POST['phone'] == "" ||
	$_POST['company'] == "" ||
	$_POST['message'] == "") {
		echo "Please fill all fields";
		http_response_code(500);
		die();
	}

	// Create email	
	$email_subject = "YOUR SUBJECT";
	$email_body = "You have received a new message. \n\n".
				  "Name: $name \nE_Mail: $e_mail \nPhone: $phone \nCompany: $company \nMessage: $message \n";

	$mail = new PHPMailer;
	$mail->isSMTP();
	$mail->SMTPDebug = 0;
	$mail->Host = 'smtp-mail.outlook.com';
	$mail->Port = 25;
	$mail->SMTPAuth = true;
	$mail->Username = 'YOUR USERNAME';
	$mail->Password = 'YOUR PASSWORD';
	$mail->setFrom('FROM WHOM', 'Your description');
	$mail->addReplyTo('TO WHOM', 'Your description');
	$mail->addAddress('CC email');
	//Set the subject line
	$mail->Subject = $email_subject;
	$mail->msgHTML($email_body);
	$mail->AltBody = $email_body;
	if (!$mail->send()) {
		echo 'Error Sending message';
	} else {
		echo 'Message sent!';
	}
?>

The above code needs to be placed in the form file that is created from blocs.
Just replace default content.

In addition you need this set of files to be uploaded to your hostdmail.zip (50.2 KB)

I hope this can help you.

1 Like