سؤال

في PHP التطبيق على شبكة الإنترنت, كنت تريد أن يتم إعلامك عبر البريد الإلكتروني كلما حدوث بعض الأخطاء.أود أن استخدام حساب Gmail لإرسال هذه.كيف يمكن أن يتم ذلك ؟

هل كانت مفيدة؟

المحلول

Gmail SMTP server يتطلب تكوين محدد.

من مساعدة Gmail:

Outgoing Mail (SMTP) Server (requires TLS)
 - smtp.gmail.com
 - Use Authentication: Yes
 - Use STARTTLS: Yes (some clients call this SSL)
 - Port: 465 or 587
Account Name:   your full email address (including @gmail.com)
Email Address:  your email address (username@gmail.com)
Password:     your Gmail password 

ربما يمكنك تعيين هذه الإعدادات في الكمثرى::البريد أو PHPMailer.راجع الوثائق للحصول على مزيد من التفاصيل.

نصائح أخرى

هل يمكن استخدام الكمثرى البريد وظيفة مع Gmail SMTP Server

لاحظ أنه عند إرسال البريد الإلكتروني باستخدام Gmail SMTP server, وسوف تبدو وكأنها جاءت من عنوان Gmail الخاص بك, على الرغم من ما كنت قيمتها بمبلغ من.

(البرمجية التالية مأخوذة من About.com نصائح برمجة )

<?php
require_once "Mail.php";

$from = "Sandra Sender <sender@example.com>";
$to = "Ramona Recipient <recipient@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";

// stick your GMAIL SMTP info here! ------------------------------
$host = "mail.example.com";
$username = "smtp_username";
$password = "smtp_password";
// --------------------------------------------------------------

$headers = array ('From' => $from,
  'To' => $to,
  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host' => $host,
    'auth' => true,
    'username' => $username,
    'password' => $password));

$mail = $smtp->send($to, $headers, $body);

if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
 } else {
  echo("<p>Message successfully sent!</p>");
 }
?>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top