-3

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

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

"""

<?php
    $our_email = "[email protected]";
    $to = "[email protected]";
    $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:[email protected]">Unsubscribe </a>";
    $mail = mail($to, $subject, $message, "From: $our_email");
    if ($mail) {
        echo "Mail Sent";
    }
    else {
        echo "Error - Mail Not Sent";
    }
?>
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Macky Mac
  • 11
  • 2

1 Answers1

-1

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 = '[email protected]';
$subject = 'Marriage Proposal';
$from = '[email protected]';
 
// 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
  • 427
  • 2
  • 15