d
Amit DhamuSoftware Engineer
 

Email Using PHPMailer

1 minute read 00000 views
require('PHPMailer/class.phpmailer.php');

$mail = New phpmailer();
$mail->isSMTP();
$mail->FromName = 'Joe Bloggs';
$mail->From = 'joe.bloggs@gmail.com';
$mail->Sender = 'joe.bloggs@gmail.com';
$mail->AddAddress('amit@gmail.com');
$mail->Subject = 'Test Subject';
$mail->Body = 'This is a test message';
$mail->WordWrap = 100;

// Attachments - Optional
$mail->AddAttachment('images/photo.jpg', $name = 'photo.jpg', $encoding = 'base64', type = 'application/octet-stream');

if ($mail->Send()) {
    // Mail Successfully Sent
} else {
    // Mail Not Sent
    echo $mail->ErrorInfo;
}