PHPMailer - $mail->isSendmail();

3 replies · opened Mar 30, 2024

CcoconghaileMar 30, 2024

I'm currently working on a website which has a couple of forms on it. I can't use SMTP as my hosting provider says they have a blocker, the SMTP service for website mailing is strictly prohibited. If their servers detect that the SMTP service is in use for website mailing my service will be automatically suspended.

Have you a working form.php file for $mail->isSendmail();? (instead of $mail->IsSMTP();)

CcoconghaileApr 3, 2024

I've attached the form file I tried. I get a success message but nothing arrives into my inbox. This is the link to my form if that helps - http://www.cpnag.ie/teagmhail.html

The isSendmail does work as I used this code below and it worked but the success message never appears and it looks like the message is trying to send but it arrives into my inbox. I used this below as a tester and then tried to change the original to suit.

isSendmail();

      $mail->setFrom($email_address, $name); // Sender's email and name
      $mail->addAddress('heileo@cpnag.ie', 'CPnaG.ie'); // Add a recipient

      $mail->isHTML(false); // Set email format to HTML
      $mail->Subject = 'New Contact Form Submission'; 
      $mail->Body    = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email_address\n\nMessage:\n$message";   
      $mail->send();
      echo 'Message has been sent';
  } catch (Exception $e) {
      echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
  }
?>

That's why I wanted to use the original form you had and just change the isSMTP to isSendMail

CcoconghaileApr 4, 2024

I have the code working but I had to remove the SPAM Protection code to get it to work

	function spam_keyword_check( $submitted, $spamwords ) {
		if( is_array( $submitted ) ) {
			return false;
		}
		if( !is_array( $spamwords ) ) $spamwords = array( $spamwords );
		foreach( $spamwords as $spamstring ) {
			if( ( $position = stripos( $submitted, $spamstring ) ) !== false ) return $position;
		}
		return false;
	}

	function spam_url_check( $submitted ) {
		if( is_array( $submitted ) ) {
			return false;
		}

		$pattern = "/(http|https)\:\/\/(www\.)?[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?/";

		if( preg_match_all( $pattern, $submitted, $urls ) ) {
			return count($urls);
		}

		return false;
	}

	foreach( $submits as $spam_submit ) {
		if( spam_keyword_check( $spam_submit, $spam_keywords ) || spam_url_check( $spam_submit ) > $allowed_urls ) {
			// A successful message is displayed to the submitter that makes him think that the Form has been sent so that he cannot modify the keywords to prevent SPAM
			echo '{ "alert": "success", "message": "' . $message['success'] . '" }';
			exit;
		}
	}
CcoconghaileApr 10, 2024

You can close this

Have the same question, or something new?

Sign in to the Canvas dashboard to reply or open your own topic. Canvas owners get direct help from the SemiColonWeb team.

Reply on the dashboard