SMTP stands for Simple Mail Transfer Protocol. It's used for sending email messages between servers or from a mail client to a mail server. SMTP is a part of the application layer of the TCP/IP protocol suite and it provides a standard way of transferring email messages between different email systems.
Send mail with attached php PHPMailer SMTP Sendinblue
We see first how to send mail using PHPMailer.
We can use 2 types of ports (587,465)
SMTP 587
SMTPS encrypted email transmissions 465
Create an HTML form for sending mail. I'm not wasting time. You will make it.
<?php
$contact_no=$_POST['cn'];
$address=$_POST['add'];
$date_of_birth=$_POST['dob'];
$experience=$_POST['ex'];
$education_qualification=$_POST['eq'];
$email=$_POST['email'];
$full_name=$_POST['fn'];
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once "PHPMailer/src/PHPMailer.php";
$folder='uploads/';
if (isset($_POST['submit']))
{
$contact_no=$_POST['cn'];
$address=$_POST['add'];
$date_of_birth=$_POST['dob'];
$experience=$_POST['ex'];
$education_qualification=$_POST['eq'];
$email=$_POST['email'];
$full_name=$_POST['fn'];
if($_FILES['upcv']['size']>0)
{
$file_img_profile = basename($_FILES['upcv']['name']);
$ext = pathinfo($file_img_profile, PATHINFO_EXTENSION);
$allow=('pdf,docx,doc');
$allow=explode(',',$allow);
foreach($allow as $key=>$extm)
{
if($ext===$extm)
{
$full_path_imagess1 = 'cn-766482_'.time().$file_img_profile;
$full_path_imagess2 = $folder.'cn-766482_'.time().$file_img_profile;
move_uploaded_file($_FILES['upcv']['tmp_name'] ,$full_path_imagess2 );
$mail = new PHPMailer(true);
$mail->setFrom($email,$full_name);
$mail->addAddress("example@gmail.com", $full_name);
$mail->isHTML(true);
$mail->Subject = "You got a mail from website(Career Form)";
$mail->Body = 'Contact Number : '.$contact_no.'
Address : '.$address.'
Date of Birth : '.$date_of_birth.'
Experience : '.$experience.'
Education Qualification : '.$education_qualification;;
$mail->addAttachment('uploads/'.$full_path_imagess1);
try
{
$mail->send();
echo "";
}
catch (Exception $e)
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
}
}
}
?>
You can use a static file for sending mail
Example: https://myweb.com/uploads/camp.pdf
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require_once "PHPMailer/src/PHPMailer.php";
$folder='uploads/';
if (isset($_POST['submit']))
{
$contact_no=$_POST['cn'];
$address=$_POST['add'];
$date_of_birth=$_POST['dob'];
$experience=$_POST['ex'];
$education_qualification=$_POST['eq'];
$email=$_POST['email'];
$full_name=$_POST['fn'];
$full_path_imagess1="YOUR FILE URL";
$mail = new PHPMailer(true);
$mail->setFrom($email,$full_name);
$mail->addAddress("example@gmail.com", $full_name);
$mail->isHTML(true);
$mail->Subject = "You got a mail from website - www.aaa.com (Career Form)";
$mail->Body = 'Contact Number : '.$contact_no.'
Address : '.$address.'
Date of Birth : '.$date_of_birth.'
Experience : '.$experience.'
Education Qualification : '.$education_qualification;;
$mail->addAttachment("https://myweb.com/uploads/camp.pdf");
try
{
$mail->send();
echo "";
}
catch (Exception $e)
{
echo "Mailer Error: " . $mail->ErrorInfo;
}
}
?>
<?php
function sendinmail($to,$toname,$subject,$body)
{
require('Mailin.php');
$mailin = new Mailin('https://api.sendinblue.com/v2.0','YOUR_API_KEY');
$data = array( "to" => array("$to"=>"$toname"),
"from" => array("example@yourmail.in","Title Name"),
"replyto" => array("example@yourmail.in","Title Name"),
"subject" => "$subject",
"text" => "$subject",
"html" => "$body",
"headers" => array("Content-Type"=> "text/html; charset=iso-8859-1","X-param1"=> "value1", "X-param2"=> "value2","X-Mailin-custom"=>"my custom value", "X-Mailin-IP"=> "102.102.1.2", "X-Mailin-Tag" => "My tag"));
$mailin->send_email($data);
}
if (isset($_POST['submit']))
{
$to="abc@gmail.com";
$toname="P Das";
$subject="My subject";
$body="Your Mail Body";
sendinmail($to,$toname,$subject,$body)
}
?>
Today we will learn how to verify email id while signup. it's very important for the real user. You ..
This is a common problem for those of you who are new to coding. While coding we often make some syn..
Warning: session start() [function.session-start]: Cannot send session cache limiter - headers alrea..
Before we use the PDO, we will know why we will use PDO.PDO Only supports object-oriented.It has man..
Deprecated: autoload() is deprecated, use spl autoload register() instead. How to replace this (my a..
getimagesize() is a PHP function that returns an array containing information about the size and typ..
Today we will know - How to login with otp in php. Here we will use php,mysql & ajax. Before tha..
Get the latest news and updates by signing up to our daily newsletter.We won't sell your email or spam you !