سلام !
اگه ممکنه یه کلاس برای ارسال ایمیل با SMTP معرفی کنید که کار باهاش راحت باشه
اگه با خود PHP هم میشه تحت SMTP میل ارسال کرد یه تیکه کد کوچیک بم بدید !
ممنون
<?php
require("class.phpmailer.php");
$mailer = new PHPMailer();
$mailer->IsSMTP();
$mailer->Host = 'ssl://smtp.gmail.com:465';
$mailer->SMTPAuth = TRUE;
$mailer->Username = '######@gmail.com'; // Change this to your gmail adress
$mailer->Password = '#######'; // Change this to your gmail password
$mailer->From = '#####@?????.com'; // This HAVE TO be your gmail adress
$mailer->FromName = 'fake'; // This is the from name in the email, you can put anything you like here
$mailer->Body = 'This is the main body of the email';
$mailer->Subject = 'This is the subject of the email';
$mailer->AddAddress('######@?????.com'); // This is where you put the email adress of the person you want to mail
if(!$mailer->Send())
{
echo "Message was not sent<br/ >";
echo "Mailer Error: " . $mailer->ErrorInfo;
}
else
{
echo "Message has been sent";
}
?>
require("class.phpmailer.php");
PHP:require("class.phpmailer.php");
فایل class.phpmailer.php رو از کجا تهیه کنم؟
<?php
// example on using PHPMailer with GMAIL
include("class.phpmailer.php");
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.gmail.com"; // sets GMAIL as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "myuser"; // GMAIL username
$mail->Password = "mypassword"; // GMAIL password
$mail->From = "[email protected]";
$mail->FromName = "my name";
$mail->Subject = "subject";
$mail->Body = "my body"; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 50; // set word wrap
$mail->AddReplyTo("[email protected]","my name");
$mail->AddCC("ايميل طرف مقابل","esme girande");
$mail->AddAttachment("آدرس فايل اتچ ", ""); // attachment
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>
<?php
// example on using PHPMailer with yahoo
include("class.phpmailer.php");
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = true; // enable SMTP authentication
$mail->SMTPSecure = "ssl"; // sets the prefix to the servier
$mail->Host = "smtp.mail.yahoo.com"; // sets yahoo as the SMTP server
$mail->Port = 465; // set the SMTP port
$mail->Username = "myuser"; // yahoo username
$mail->Password = "mypassword"; // yahoo password
$mail->From = "[email protected]";
$mail->FromName = "my name";
$mail->Subject = "subject";
$mail->Body = "my body"; //HTML Body
$mail->AltBody = "This is the body when user views in plain text format"; //Text Body
$mail->WordWrap = 50; // set word wrap
$mail->AddReplyTo("[email protected]","my name");
$mail->AddCC("ايميل طرف مقابل","esme girande");
$mail->AddAttachment("آدرس فايل اتچ ", ""); // attachment
$mail->IsHTML(true); // send as HTML
if(!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message has been sent";
}
?>
$mail->AddCC("ايميل طرف مقابل","esme girande");
میشه همزمان یه ایمیل رو واسه چندید نفر بفرستیم؟ بین هر ایمیل کاما بزاریم؟
$mail->[B]AddBCC[/B]("ايميل 1","");
$mail->[B]AddBCC[/B]("ايميل 2","");
...
$mail->AddCC("ايميل طرف مقابل","esme girande");
$mail->AddBCC("ايميل 1","");
$mail->AddBCC("ايميل 2","");
...
ini_set('max_execution_time',600);
include("class.phpmailer.php");
یعنی به جای
PHP:$mail->AddCC("ايميل طرف مقابل","esme girande");
بزنم؟
PHP:$mail->AddBCC("ايميل 1",""); $mail->AddBCC("ايميل 2",""); ...
این کد:
PHP:ini_set('max_execution_time',600);
هم قبل از
PHP:include("class.phpmailer.php");
بزارم موردی نداره؟:wacko:
قصد ایمیل تبلیغاتی، اسپم ندارم...
و یه سوال دیگه، منظوز از 600 تو اون کد صبر چیه؟:d چقدر صبر میکنه و بعدی رو ارسال میکنه؟ به نظر شما اینقدر کافیه؟
منظورتون اینه که هر کودوم ایمیل رو که فرستاد 600 ثانیه صبر میکنه؟!
نه ، ماكزيمم زمان اجراي اسكريپته كه باعث ميشه 100 تا ايميل رو بفرسته !