Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php mail function from name

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: Jack Sparrow <jsparrow@blackpearl.com>' . PHP_EOL .
    'Reply-To: Jack Sparrow <jsparrow@blackpearl.com>' . PHP_EOL .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>
Comment

php mail

<?php
    mail("recipient@example.com",
        "This is the message subject",
        "This is the message body",
        "From: sender@example.com" . "
" . "Content-Type: text/plain; charset=utf-8",
        "-fsender@example.com");
?>
Comment

send-email.php

<?php

$name = $_POST["name"];
$email = $_POST["email"];
$subject = $_POST["subject"];
$message = $_POST["message"];

require "vendor/autoload.php";

use PHPMailerPHPMailerPHPMailer;
use PHPMailerPHPMailerSMTP;

$mail = new PHPMailer(true);

// $mail->SMTPDebug = SMTP::DEBUG_SERVER;

$mail->isSMTP();
$mail->SMTPAuth = true;

$mail->Host = "smtp.example.com";
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
$mail->Port = 587;

$mail->Username = "you@example.com";
$mail->Password = "password";

$mail->setFrom($email, $name);
$mail->addAddress("dave@example.com", "Dave");

$mail->Subject = $subject;
$mail->Body = $message;

$mail->send();

header("Location: sent.html");
Comment

php mail()

mail( to, subject, message, headers, parameters );
Comment

PHP email sender

<?php
$url = 'https://api.elasticemail.com/v2/email/send';

try{
        $post = array('from' => 'youremail@yourdomain.com',
		'fromName' => 'Your Company Name',
		'apikey' => '00000000-0000-0000-0000-000000000000',
		'subject' => 'Your Subject',
		'to' => 'recipient1@gmail.com;recipient2@gmail.com',
		'bodyHtml' => '<h1>Html Body</h1>',
		'bodyText' => 'Text Body',
		'isTransactional' => false);
		
		$ch = curl_init();
		curl_setopt_array($ch, array(
            CURLOPT_URL => $url,
			CURLOPT_POST => true,
			CURLOPT_POSTFIELDS => $post,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER => false,
			CURLOPT_SSL_VERIFYPEER => false
        ));
		
        $result=curl_exec ($ch);
        curl_close ($ch);
		
        echo $result;	
}
catch(Exception $ex){
	echo $ex->getMessage();
}
?>
Comment

php email

mail ( string $to , string $subject , string $message [, mixed $additional_headers [, string $additional_parameters ]] ) : bool
Comment

php mail

mnjah
Comment

PREVIOUS NEXT
Code Example
Php :: laravel echo query 
Php :: how to replace multiple characters in a string in php 
Php :: laravel validate enum field 
Php :: convert multi-dimensional array into a single array in laravel 
Php :: count remaining days php 
Php :: refresh a specific migration laravel 
Php :: pass variable to another page in js 
Php :: turnery expression php 
Php :: laravel artisan cache clear 
Php :: redirect back with input laravel in request 
Php :: php start of day epoch 
Php :: laravel timestamp 
Php :: define("ROOT PATH", __DIR__); 
Php :: permissions for laravel deployment 
Php :: set session after login with laravel 
Php :: how to check php version in php 
Php :: phpcs 
Php :: get last letter in php 
Php :: php clone 
Php :: yii2 postgresql connection 
Php :: php eliminar elementos vacios array 
Php :: how to zip a folder using php 
Php :: php mac address 
Php :: Exception::getMessage in php 
Php :: codeingiter 3 where in 
Php :: add to json object php 
Php :: unset session key 
Php :: php remove leading zeros 
Php :: php exception import 
Php :: destroy all sessions in laravel 
ADD CONTENT
Topic
Content
Source link
Name
6+2 =