-3

I am trying to send emails using a php script whose code is below. What is the error in the code? Parsing error is:

PHP Parse error: syntax error, unexpected 'https' (T_STRING) in /workspace/Main.php on line 9

"""

<?php
$our_email = "agrawal.shivam@godonphone.website";
$to = "agrawal.shivam2602@gmail.com";
$from = $our_email;
$subject = "God Apps on Mobile Phone";
$message = "
God on Mobile! Please go through these contents for your personal growth & distribute to others as well:

echo '<a href="http://krishna.science.blog">krishna.science.blog</a>';

Share the Love & Knowledge in your physical proximity also.

Physical address: Krishna, Vrindavan, Uttar Pradesh, India (IN), Pin Code:- 281121

echo '<a href="mailto:agrawal.shivam@godonphone.website">Unsubscribe </a>";
$mail = mail($to, $subject, $message, "From: $our_email");
if ($mail) {
echo "Mail Sent";
}
else {
echo "Error - Mail Not Sent";
}
?>
Macky Mac
  • 11
  • 2

1 Answers1

0

Your message is not your website PHP file. You just need to show that the message you are sending is HTML, and write pure HTML instead of using echo PHP statements.

To send HTML use

 <?php
$to = 'maryjane@email.com';
$subject = 'Marriage Proposal';
$from = 'peterparker@email.com';
 
// To send HTML mail, the Content-type header must be set
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 
// Create email headers
$headers .= 'From: '.$from."\r\n".
    'Reply-To: '.$from."\r\n" .
    'X-Mailer: PHP/' . phpversion();
 
// Compose a simple HTML email message
$message = '<html><body>';
$message .= '<h1 style="color:#f40;">Hi Jane!</h1>';
$message .= '<p style="color:#080;font-size:18px;">Will you marry me?</p>';
$message .= '</body></html>';
 
// Sending email
if(mail($to, $subject, $message, $headers)){
    echo 'Your mail has been sent successfully.';
} else{
    echo 'Unable to send email. Please try again.';
}
?>

As per https://www.tutorialrepublic.com/php-tutorial/php-send-email.php

Undry
  • 401
  • 2
  • 13
  • how to resolve:- PHP Parse error: syntax error, unexpected 'https' (T_STRING) in /workspace/Main.php on line 9. Line 9 is: echo 'krishna.science.blog'; – Macky Mac Aug 22 '20 at 06:27
  • Echo is a PHP command. It should be used in PHP code. What you are sending is not a PHP, you are sending HTML. Don't use PHP in HTML messages. – Undry Aug 23 '20 at 12:09