Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
AWS Certified Solutions Architect-Associate + AWS Certified Cloud Practitioner
Sanjeewani95
Updated:
Wednesday at 8:16 PM
🚀 එක පැකේජ් එකයි - මාසෙටම Unlimited Internet! 🌐
sayuru bandara
Updated:
Tuesday at 10:57 AM
🎬 CapCut Pro 1 Month Access! LKR 600
sayuru bandara
Updated:
Tuesday at 10:55 AM
🚀 Google One AI PRO Plan (Gemini Pro Activation) – 18 Months Access! LKR 2200
sayuru bandara
Updated:
Tuesday at 10:53 AM
Canva Pro Lifetime Own Mail Activation LKR 500
sayuru bandara
Updated:
Tuesday at 10:51 AM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
Computers & Internet
Software Development
PHP වලින් EMAIL එකක් යවන්න CODE කරන එක හෙන අමාරු වැඩක්ද ?
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="dilsh7" data-source="post: 29397410" data-attributes="member: 562366"><p>To send an email in PHP, you can use the mail() function. Here's a simple example:</p><p></p><p>php</p><p></p><p><?php</p><p>$to = "<a href="mailto:recipient@example.com">recipient@example.com</a>";</p><p>$subject = "Test Email";</p><p>$message = "This is a test email sent from PHP.";</p><p>$headers = "From: <a href="mailto:sender@example.com">sender@example.com</a>";</p><p></p><p>// Send email</p><p>$mailSent = mail($to, $subject, $message, $headers);</p><p></p><p>if ($mailSent) {</p><p>echo "Email sent successfully.";</p><p>} else {</p><p>echo "Error sending email.";</p><p>}</p><p>?></p><p></p><p>In this example:</p><p></p><ul> <li data-xf-list-type="ul">Replace "<a href="mailto:recipient@example.com">recipient@example.com</a>" with the actual email address of the recipient.</li> <li data-xf-list-type="ul">Replace "<a href="mailto:sender@example.com">sender@example.com</a>" with the actual email address of the sender.</li> <li data-xf-list-type="ul">Modify the $subject and $message variables according to your needs.</li> </ul><p>Note that the mail() function relies on the mail configuration of your server. Make sure your server is configured to send emails, or consider using a third-party library like PHPMailer or Swift Mailer for more advanced features and better control over the email sending process.</p><p></p><p>Here's an example using PHPMailer:</p><p></p><p>php</p><p></p><p><?php</p><p>use PHPMailer\PHPMailer\PHPMailer;</p><p>use PHPMailer\PHPMailer\Exception;</p><p></p><p>require 'vendor/autoload.php'; // Make sure to include the autoloader from PHPMailer</p><p></p><p>$mail = new PHPMailer(true);</p><p></p><p>try {</p><p>// Server settings</p><p>$mail->isSMTP();</p><p>$mail->Host = 'smtp.example.com'; // Your SMTP server</p><p>$mail->SMTPAuth = true;</p><p>$mail->Username = 'your_username';</p><p>$mail->Password = 'your_password';</p><p>$mail->SMTPSecure = 'tls';</p><p>$mail->Port = 587;</p><p></p><p>// Recipients</p><p>$mail->setFrom('<a href="mailto:sender@example.com">sender@example.com</a>', 'Your Name');</p><p>$mail->addAddress('<a href="mailto:recipient@example.com">recipient@example.com</a>', 'Recipient Name');</p><p></p><p>// Content</p><p>$mail->isHTML(true);</p><p>$mail->Subject = 'Test Email';</p><p>$mail->Body = 'This is a test email sent from PHP using PHPMailer.';</p><p></p><p>$mail->send();</p><p>echo 'Email sent successfully.';</p><p>} catch (Exception $e) {</p><p>echo 'Error sending email: ', $mail->ErrorInfo;</p><p>}</p><p>?></p><p></p><p>Remember to install PHPMailer using Composer (composer require phpmailer/phpmailer) before using it in your project. Adjust the settings such as SMTP server, username, password, and other parameters based on your email provider.</p></blockquote><p></p>
[QUOTE="dilsh7, post: 29397410, member: 562366"] To send an email in PHP, you can use the mail() function. Here's a simple example: php <?php $to = "[email]recipient@example.com[/email]"; $subject = "Test Email"; $message = "This is a test email sent from PHP."; $headers = "From: [email]sender@example.com[/email]"; // Send email $mailSent = mail($to, $subject, $message, $headers); if ($mailSent) { echo "Email sent successfully."; } else { echo "Error sending email."; } ?> In this example: [LIST] [*]Replace "[email]recipient@example.com[/email]" with the actual email address of the recipient. [*]Replace "[email]sender@example.com[/email]" with the actual email address of the sender. [*]Modify the $subject and $message variables according to your needs. [/LIST] Note that the mail() function relies on the mail configuration of your server. Make sure your server is configured to send emails, or consider using a third-party library like PHPMailer or Swift Mailer for more advanced features and better control over the email sending process. Here's an example using PHPMailer: php <?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'vendor/autoload.php'; // Make sure to include the autoloader from PHPMailer $mail = new PHPMailer(true); try { // Server settings $mail->isSMTP(); $mail->Host = 'smtp.example.com'; // Your SMTP server $mail->SMTPAuth = true; $mail->Username = 'your_username'; $mail->Password = 'your_password'; $mail->SMTPSecure = 'tls'; $mail->Port = 587; // Recipients $mail->setFrom('[email]sender@example.com[/email]', 'Your Name'); $mail->addAddress('[email]recipient@example.com[/email]', 'Recipient Name'); // Content $mail->isHTML(true); $mail->Subject = 'Test Email'; $mail->Body = 'This is a test email sent from PHP using PHPMailer.'; $mail->send(); echo 'Email sent successfully.'; } catch (Exception $e) { echo 'Error sending email: ', $mail->ErrorInfo; } ?> Remember to install PHPMailer using Composer (composer require phpmailer/phpmailer) before using it in your project. Adjust the settings such as SMTP server, username, password, and other parameters based on your email provider. [/QUOTE]
Insert quotes…
Verification
Hathara warak wissa keeyada? (Hathara wadi karanna 20)
Post reply
Top
Bottom