Untitled

 avatar
unknown
plain_text
a year ago
751 B
4
Indexable
<?php
// Sending email
$to = "recipient@example.com";
$subject = "Hello from PHP!";
$message = "This is a plain text email sent from a PHP script.";
$headers = "From: sender@example.com";

// Send email
if (mail($to, $subject, $message, $headers)) {
    echo "Email sent successfully!";
} else {
    echo "Failed to send email.";
}

// Receiving email
$inbox = imap_open('{imap.example.com:993/ssl}INBOX', 'username', 'password');

// Check for new messages
$emails = imap_search($inbox, 'UNSEEN');

if ($emails) {
    foreach ($emails as $email_number) {
        $message = imap_fetchbody($inbox, $email_number, 1.2);
        echo "Received email: " . $message;
    }
} else {
    echo "No new emails.";
}

// Close connection
imap_close($inbox);
?>
Editor is loading...
Leave a Comment