B
B
braindev2022-01-08 21:30:36
gmail
braindev, 2022-01-08 21:30:36

PHPMailer accepting emails to Gmail business mail (G-Suite)?

Greetings! Please tell me, what are the nuances with sending and receiving letters to Google mail? Such a magical thing that even a spam letter does not reach business mail, but ordinary letters reach the inbox, what could be the matter? Thank you very much for your attention, I will be glad to any hint, thanks. Code below

[code=php]<?php
header('Content-type: application/json');
require_once('php-mailer/PHPMailerAutoload.php'); // Include PHPMailer

$mail = new PHPMailer();
$emailTO = $emailBCC = $emailCC = array();

// Enter Your Sitename
$sitename = 'SiteName';

// Enter your email addresses: @required
$emailTO[] = array( 'email' => '[email protected]', 'name' => 'Your Name' );

// Enable bellow parameters & update your BCC email if require.
$emailBCC[] = array( 'email' => 'mygmailhere', 'name' => 'Your Name' );

// Enable bellow parameters & update your CC email if require.
//$emailCC[] = array( 'email' => '[email protected]', 'name' => 'Your Name' );

// Enter Email Subject
$subject = "New Quote Request" . ' - ' . $sitename;

// Success Messages
$msg_success = "We have successfully received your request. We'll get back to you soon.";

if( $_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST["quote-request-email"]) && $_POST["quote-request-email"] != '
$qr_email = $_POST["quote-request-email"];
$qr_name = $_POST["quote-request-name"];

$qr_phone = isset($_POST["quote-request-phone"]) ? $_POST["quote-request-phone"] : '';
$qr_company = isset($_POST["quote-request-company"]) ? $_POST["quote-request-company"] : '';
$qr_reach = isset($_POST["quote-request-reach"]) ? $_POST["quote-request-reach"] : '';
$qr_hear = isset($_POST["quote-request-hear"]) ? $_POST["quote-request-hear"] : '';

$qr_interest = isset($_POST["quote-request-interest"]) ? $_POST["quote-request-interest"] : '';
$qr_interested = '';
if (is_array($qr_interest)) {
foreach ($qr_interest as $interest) {
$qr_interested .= ', '.$interest;
}
} else {
$qr_interested = $qr_interest;
}
$qr_interested = ($qr_interested !='') ? substr($qr_interested, 2) : '';

$qr_message = isset($_POST["quote-request-message"]) ? $_POST["quote-request-message"] : '';

$honeypot = isset($_POST["form-anti-honeypot"]) ? $_POST["form-anti-honeypot"] : '';
$bodymsg = '';

if ($honeypot == '' && !(empty($emailTO))) {
$mail->IsHTML(true);
$mail->CharSet = 'UTF-8';

$mail->From = $qr_email;
$mail->FromName = $sitename;
$mail->AddReplyTo($qr_email);
$mail->Subject = $subject;

foreach( $emailTO as $to ) {
$mail->AddAddress( $to['email'] , $to['name'] );
}

// if CC found
if (!empty($emailCC)) {
foreach( $emailCC as $cc ) {
$mail->AddCC( $cc['email'] , $cc['name'] );
}
}

// if BCC found
if (!empty($emailBCC)) {
foreach( $emailBCC as $bcc ) {
$mail->AddBCC( $bcc['email'] , $bcc['name'] );
}
}

// Include Form Fields into Body Message
$bodymsg .= isset($qr_name) ? "Name: $qr_name
" : '';
$bodymsg .= isset($qr_email) ? "Email: $qr_email
" : '';
$bodymsg .= isset($qr_phone) ? "Phone: $qr_phone
" : '';
$bodymsg . = isset($qr_company) ?
"Company: $qr_company " : '';
$bodymsg .= isset($qr_interested) ? "Services Interested: $qr_interested
" : '';
$bodymsg .= isset($qr_reach) ? "Time to Reach: $qr_reach
" : '';
$bodymsg .= isset($qr_hear) ? "Hear From: $qr_hear
" : '';
$bodymsg .= isset($qr_message) ? "Messages: $qr_message
" : '';
$bodymsg .= $_SERVER['HTTP_REFERER'] ? '
---
This email was sent from: ' . $_SERVER['HTTP_REFERER'] : '';

$mail->MsgHTML( $bodymsg );
$is_emailed = $mail->Send();

if( $is_emailed === true ) {
$response = array ('result' => "success", 'message' => $msg_success);
} else {
$response = array ('result' => "error", 'message' => $mail->ErrorInfo);
}
echo json_encode($response);

} else {
echo json_encode(array ('result' => "error", 'message' => "Bot Detected! Please try later."));
}
} else {
echo json_encode(array ('result' => "error", 'message' => "Please Fill up all required fields and try again."));
}
}[/code]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2022-01-08
@ky0

Google doesn't care what you send mail. If the reverse zone for the IP address from which the message is being sent is registered, there are corresponding SPF and DKIM records, there should be no problems (provided, of course, that you do not spam and in general the letter looks like a letter, and not like a malware).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question