שליחת מייל בphp
-
@לעזור-לכולם צריך קודם להתקין ולהגדיר משהו, לא?
ומאיזה זיהוי זה ייצא? -
@שמואל-ש כתב בשליחת מייל בphp:
צריך קודם להתקין ולהגדיר משהו, לא?
לא צריך בדרך כלל (תלוי באיזה שרת אתה עובד)
@שמואל-ש כתב בשליחת מייל בphp:
ומאיזה זיהוי זה ייצא
פה יש לך הסבר בעברית ויותר ברור
-
@לעזור-לכולם זה מה שראיתי שם תוכל להסביר לי איזה פרטים אני מכניס?
<?php function sendHTMLemail($to, $subject, $from, $body) { if (ereg("(.*)< (.*)>", $from, $regs)) { $from = '=?UTF-8?B?'.base64_encode($regs[1]).'?= < '.$regs[2].'>'; } else { $from = $from; } $headers = "From: $fromrn"; $headers .= "MIME-Version: 1.0rn"; $boundary = uniqid("HTMLEMAIL"); $headers .= "Content-Type: multipart/alternative;". "boundary = $boundaryrnrn"; $headers .= "This is a MIME encoded message.rnrn"; $headers .= "--$boundaryrn". "Content-Type: text/plain; UTF-8rn". "Content-Transfer-Encoding: base64rnrn"; $headers .= chunk_split(base64_encode(strip_tags($body))); $headers .= "--$boundaryrn". "Content-Type: text/html; charset=UTF-8rn". "Content-Transfer-Encoding: base64rnrn"; $headers .= chunk_split(base64_encode($body)); $result = mail($to,'=?UTF-8?B?'.base64_encode($subject).'?=',"",$headers); return $result;
-
@לעזור-לכולם @שמואל-ש או שזה זה
<?php $to = 'ran@bar-zik.com'; $subject = 'SUBJECT'; $message = 'BODY'; $headers = 'From: ran@bar-zik.com' . "rn" . 'Reply-To: ran@bar-zik.com' . "rn" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers);
-
@לעזור-לכולם @שמואל-ש
זה קוד עובד רק השאלה איך אני יכול לעשות שיצורפו קבצים מהשרת<?php $to = 'ran@bar-zik.com'; $subject = 'SUBJECT'; $message = 'BODY'; $headers = 'From: ran@bar-zik.com' . "rn" . 'Reply-To: ran@bar-zik.com' . "rn" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers);
-
@121244 יש כזה דבר TBV VEUS```
עבור לתוכן הדף
תכנות אתרי אינטרנט ומדריכיםשליחת email מעוצב בעברית עם PHP
מחבר: יוסי בן הרוש בתאריך: 19.09.2013
במדריך זה נלמד כיצד לשלוח מייל PHP מעוצב בעברית. בחרתי להדגים על שנה טובה, שכוללת עיצוב פשוט ותמונה. אתם מוזמנים להתאים את התוכן והצורה לפי הצורך. כך ייראה ה-email המוכן:שנה טובה
שלום לכולם,רציתי לאחל שנה טובה ומוצלחת
מדגים תמונה שניתן לשבץ במייל
מיוסי.
לאתר השולח
<?php $to=$_GET['to']; $subject=$_GET['subject']; $message=$_GET['message']; $headers= array( "From: " . "פה יש לרשום כתובת המייל ממנה ישלך", "Reply-To: " . "לאן אים ישלך תגובה לאן התגובה תגיע", "Content-Type: text/html; charset=utf-8", ); $headers = implode("\r\n", $headers); if($to==null){print"read=t-בחר כתובת אימייל.=to,,,,,EmailKeyboard,,";exit();} elseif($subject==null){print"read=t-בחרו את נושא האימייל.=subject,,,,,HebrewKeyboard,,";exit();} elseif($message==null){print"read=t-בחרו את תוכן האימייל.=message,,,,,HebrewKeyboard,,";exit();} mail($to, $subject, $message, $headers); print"id_list_message=m-2573";
-
@רק-טוב
תודה רבה רבה!!
אך אם אפשר שתעשה את ההודעה יותר ברורה -
@צצ בסדר סידרתי
-
@רק-טוב
תודה רבה רבה...
זה יכול להיות מאד מאד שימושי לכולם... -
עדיף להשתמש ב-PHPMailer.
קודם כל יש להוריד את החבילה באמצעות composer:
composer require phpmailer/phpmailer
וזה קוד לדוגמא:
<?php use PHPMailer\PHPMailer\PHPMailer; use PHPMailer\PHPMailer\Exception; require 'vendor/autoload.php'; // Include Composer's autoloader $mail = new PHPMailer(true); try { // SMTP Configuration $mail->isSMTP(); $mail->Host = 'smtp.example.com'; // Replace with your SMTP host $mail->SMTPAuth = true; $mail->Username = 'your_email@example.com'; // Your email $mail->Password = 'your_email_password'; // Your email password $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS; // Use `PHPMailer::ENCRYPTION_SMTPS` for SSL $mail->Port = 587; // Change to 465 if using SSL // Sender & Recipient $mail->setFrom('your_email@example.com', 'Your Name'); $mail->addAddress('recipient@example.com', 'Recipient Name'); // Attachments $mail->addAttachment('/path/to/file.pdf'); // Example: Attach a PDF $mail->addAttachment('/path/to/image.jpg', 'CustomFileName.jpg'); // Rename attachment // Email Content $mail->isHTML(true); $mail->Subject = 'Test Email with Attachment'; $mail->Body = '<h3>Hello,</h3><p>This is a test email with an attachment.</p>'; $mail->AltBody = 'Hello, This is a test email with an attachment.'; // Plain text fallback // Send Email $mail->send(); echo 'Email sent successfully!'; } catch (Exception $e) { echo "Email could not be sent. Error: {$mail->ErrorInfo}"; } ?>
-
@soris1989 בניתי קוד חדש אינה
<?php $to=$_GET['to']; $subject=$_GET['subject']; $message=$_GET['message']; $headers= array( "From: " . "פה יש לרשום כתובת המייל ממנה ישלך", "Reply-To: " . "לאן אים ישלך תגובה לאן התגובה תגיע", "Content-Type: text/html; charset=utf-8", ); $headers = implode("\r\n", $headers); if($to==null){print"read=t-בחר כתובת אימייל.=to,,,,,EmailKeyboard,,";exit();} elseif($subject==null){print"read=t-בחרו את נושא האימייל.=subject,,,,,HebrewKeyboard,,";exit();} elseif($message==null){print"read=t-בחרו את תוכן האימייל.=message,,,,,HebrewKeyboard,,";exit();} mail($to, $subject, $message, $headers); print"id_list_message=m-2573";
-
@רק-טוב מה שעשית זה מעולה, רק שבתור המלצה יהיה תמיד עדיף להשתמש ב-PHPMailer מאשר להשתמש ב-mail.