Changing From Email for Forms

3 replies · opened May 17, 2016

Rravisasthri832May 17, 2016

Hi,

This is Ravikumar Pendyala.

When I am submitting the form by using sendemail-autoresponder.php, the mail is triggering to both sender and receiver properly but...
Coming to receiver side the email is triggering with the name of "Root User". And it shows that the email is triggering from root@localhost.
But I am trying to send using tadhastu@poojalu.com email id. Please find the below attached code & image. I am Waiting for your valuable suggestion.

My Code:

 'tadhastu@poojalu.com', // Your Email Address
				'name' => 'Pandit Services' // Your Name
			);

// Form Processing Messages
$message_success = 'We have **successfully** received your Message and will get Back to you as soon as possible.';

// Add this only if you use reCaptcha with your Contact Forms
$recaptcha_secret = 'your-recaptcha-secret-key'; // Your reCaptcha Secret

$mail = new PHPMailer();
$autoresponder = new PHPMailer();

// If you intend you use SMTP, add your SMTP Code after this Line

if( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
	if( $_POST['emailid'] != '' ) {

		$name = isset( $_POST['name'] ) ? $_POST['name'] : '';
		$email = isset( $_POST['emailid'] ) ? $_POST['emailid'] : '';
		$phone = isset( $_POST['phone'] ) ? $_POST['phone'] : '';
		$service = isset( $_POST['service'] ) ? $_POST['service'] : '';
		$subject = isset( $_POST['subject'] ) ? $_POST['subject'] : '';
		$message = isset( $_POST['message'] ) ? $_POST['message'] : '';

		$subject = isset($subject) ? $subject : 'New Message From Contact Form';

		$botcheck = $_POST['botcheck'];

		if( $botcheck == '' ) {

			$mail->SetFrom( $email , $name );
			$mail->AddReplyTo( $email , $name );
			foreach( $toemails as $toemail ) {
				$mail->AddAddress( $toemail['email'] , $toemail['name'] );
			}
			$mail->Subject = $subject;

			// AutoResponder Settings
			$autoresponder->SetFrom( $toemail , $toname );
			$autoresponder->AddReplyTo( $toemail , $toname );
			$autoresponder->AddAddress( $email , $name );
			$autoresponder->Subject = 'We\'ve received your Email';

			$name = isset($name) ? "Name: $name

" : '';
			$email = isset($email) ? "Email: $email

" : '';
			$phone = isset($phone) ? "Phone: $phone

" : '';
			$service = isset($service) ? "Service: $service

" : '';
			$message = isset($message) ? "Message: $message

" : '';

			$referrer = $_SERVER['HTTP_REFERER'] ? '

This Form was submitted from: ' . $_SERVER['HTTP_REFERER'] : '';

			$body = "$name $email $phone $service $message $referrer";

			// AutoResponder Message
			$ar_body = "Thank you for contacting us. We will reply within 24 hours.

Regards,
Your Company.";

			// Runs only when File Field is present in the Contact Form
			if ( isset( $_FILES['file'] ) && $_FILES['file']['error'] == UPLOAD_ERR_OK ) {
				$mail->IsHTML(true);
				$mail->AddAttachment( $_FILES['file']['tmp_name'], $_FILES['file']['name'] );
			}

			// Runs only when reCaptcha is present in the Contact Form
			if( isset( $_POST['g-recaptcha-response'] ) ) {
				$recaptcha_response = $_POST['g-recaptcha-response'];
				$response = file_get_contents( "https://www.google.com/recaptcha/api/siteverify?secret=" . $recaptcha_secret . "&response=" . $recaptcha_response );

				$g_response = json_decode( $response );

				if ( $g_response->success !== true ) {
					echo '{ "alert": "error", "message": "Captcha not Validated! Please Try Again." }';
					die;
				}
			}

			$mail->MsgHTML( $body );
			$autoresponder->MsgHTML( $ar_body );
			$sendEmail = $mail->Send();

			if( $sendEmail == true ):
				$send_arEmail = $autoresponder->Send();
				echo '{ "alert": "success", "message": "' . $message_success . '" }';
			else:
				echo '{ "alert": "error", "message": "Email **could not** be sent due to some Unexpected Error. Please Try Again later.

**Reason:**
' . $mail->ErrorInfo . '" }';
			endif;
		} else {
			echo '{ "alert": "error", "message": "Bot **Detected**.! Clean yourself Botster.!" }';
		}
	} else {
		echo '{ "alert": "error", "message": "Please **Fill up** all the Fields and Try Again." }';
	}
} else {
	echo '{ "alert": "error", "message": "An **unexpected error** occured. Please Try Again later." }';
}

?>``
SSemicolon WebSTAFFMay 17, 2016

Hello,

Simply find the following code in the include/sendemail.php File:

$mail->SetFrom( $email , $name );
$mail->AddReplyTo( $email , $name );

and change the $email to 'tadhastu@poojalu.com'.

This should definitely work fine. Let us know if we can help you with anything else or if you find any further issues.

Rravisasthri832Jun 27, 2016

Thanks for your suggestion. Email triggering properly but, though I change the email value to tadhastu@poojalu.com it is triggering form root@localhost.
I am not able to find where the exact issue is.
Please find the attachment for further.

SSemicolon WebSTAFFJul 2, 2016

Hello,

We Really Apologize but there was a Minor Bug in the Code of the include/sendemail-autoresponder.php File. We have fixed this in the Latest Update. Please update this File to the Latest Version and your issue will be automatically resolved.

Let us know if we can help you with anything else or if you find any further issues.

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