Skip to content

Instantly share code, notes, and snippets.

@unique1984
Last active August 17, 2019 12:33
Show Gist options
  • Select an option

  • Save unique1984/63ff6e83fa9cc8b107888552cf581359 to your computer and use it in GitHub Desktop.

Select an option

Save unique1984/63ff6e83fa9cc8b107888552cf581359 to your computer and use it in GitHub Desktop.
PHP Mailer Example
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!-- charset= -->
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>PHPMailer Test</title>
</head>
<body>
<div style="width: 640px; font-family: Arial, Helvetica, sans-serif; font-size: 11px;">
<h1>This is a test of PHPMailer.</h1>
<div align="center">
<a href="https://github.com/PHPMailer/PHPMailer/"><img src="images/phpmailer.png" height="90" width="340" alt="PHPMailer rocks"></a>
</div>
<p>This example uses <strong>HTML</strong>.</p>
<p>ISO-8859-1 text: ИХНЭГеЯФъ</p>
<p><img src="images/phpmailer_mini.png" height="100" width="100" border="0"></p>
</div>
</body>
</html>
<?php
require '../PHPMailerAutoload.php';
$smtp_settings=array(
"SMTPAuth" => true,
"SMTPSecure" => "ssl", // büyük küçük harf duyarlı o yüzden yandex için küçük harf çalışmakta
"Host" => "smtp.yandex.com.tr",
"Port" => "465",
"Username" => "...@yandex.com.tr",
"From" => "...@yandex.com.tr",
"FromName" => "Yasin KARABULAK",
"Password" => "p@ssw0rd",
"Subject" => "SMTP Test"
);
$mail_gonderilecek = "...@gmail.com";
$mail = new PHPMailer();
$mail->CharSet = "UTF-8";
$mail->IsSMTP();
$mail->SMTPDebug = 2; //full açıklama
//~ $mail->SMTPDebug = 0; // production
$mail->SMTPAuth = $smtp_settings["SMTPAuth"];
$mail->SMTPSecure = $smtp_settings["SMTPSecure"];
$mail->Host = $smtp_settings["Host"];
$mail->Port = $smtp_settings["Port"];
$mail->Username = $smtp_settings["Username"];
$mail->From = $smtp_settings["From"];
$mail->FromName = $smtp_settings["FromName"];
$mail->Password = $smtp_settings["Password"];
$mail->AddAddress($mail_gonderilecek);
$mail->Subject = $smtp_settings["Subject"];
$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->AltBody = 'This is a plain-text message body';
$mail->addAttachment('images/phpmailer_mini.png');
if (!$mail->send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
//print_r($smtp_settings);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment