php/ html

when I send the email, if the subject says "Ç", it shows "?".

already tried to implement:

-charset="ascii";

-charset=UTF-8;

-$mail->$subject = "=?ISO-8859-1?Q?".imap_8bit("äöüßÄÖÜ sollte hier gehen")."?=";

-$mail->$subject = '=?UTF-8?B?'.base64_encode(utf8_encode("çççç")).'?=';

So far I can not solve this, what else can I do? I already searched in the forum has a lot of post to talk about it but none solved my problem.

My exemple code is :

 $mail = new PHPMailer(); $mail->charset="UTF-8"; $mail->IsSMTP(); $mail->Host = "*.*.*.*:*"; $mail->SMTPAuth = false; $mail->From = "*@*.*"; $mail->FromName = "newjob"; $mail->addAddress($add1, $addnome1); if($add2!=""){ $mail->addAddress($add2, $addnome2);}; if($add3!=""){ $mail->addAddress($add3, $addnome3);}; $mail->ContentType = 'text/calendar; charset=utf-8'; $mail->$subject = "=?ISO-8859-1?Q?".imap_8bit("äöüßÄÖÜ")."?="; // $mail->$subject = '=?UTF-8?B?'.base64_encode(utf8_encode("çççç")).'?='; $ical = "BEGIN:VCALENDAR\\r\\n"; $ical .= "VERSION:2.0\\r\\n"; $ical .= "PRODID:-sigma.eda.pt\\r\\n"; $ical .= "METHOD:PUBLISH\\r\\n"; $ical .= "BEGIN:VEVENT\\r\\n"; $ical .= "ORGANIZER;SENT-BY=\\"MAILTO:$add1\\r\\n"; $ical .= "ATTENDEE;CN=$add1;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;RSVP=false:mailto:$add1\\r\\n"; $ical .= "UID:".strtoupper(md5($event_id))."-sigma.eda.pt\\r\\n"; $ical .= "SEQUENCE:".$sequence."\\r\\n"; $ical .= "STATUS:".$status."\\r\\n"; $ical .= "DTSTAMPTZID=Europe/azores:".date('Ymd').'T'.date('His')."\\r\\n"; $ical .= "DTSTART:".$start."T".$start_time."\\r\\n"; $ical .= "DTEND:".$end."T".$end_time."\\r\\n"; $ical .= "LOCATION:".$venue."\\r\\n"; $ical .= "SUMMARY:".$summary."\\r\\n"; $ical .= "DESCRIPTION:".$descr."\\r\\n"; $ical .= "RRULE:FREQ=MONTHLY;INTERVAL=".$rotina.";COUNT=".$repete.";\\r\\n"; $ical .= "BEGIN:VALARM\\r\\n"; $ical .= "TRIGGER:-PT15M\\r\\n"; $ical .= "ACTION:DISPLAY\\r\\n"; $ical .= "DESCRIPTION:Reminder\\r\\n"; $ical .= "END:VALARM\\r\\n"; $ical .= "END:VEVENT\\r\\n"; $ical .= "END:VCALENDAR\\r\\n"; $mail->Body = $ical; try { if ( !$mail->Send() ) { // $error = "Unable to send the email <br />"; // throw new phpmailerAppException($error); } else { // echo 'Message has been sent<br /><br />'; } } catch (phpmailerAppException $e) { // $errorMsg[] = $e->errorMessage(); } 

EDIT image error from test:

这里

PHP has case sensitive class properties, which means that when a property has a name CharSet , it has to be defined like this and not in lowercase $mail->charset . This also aplies to $mail->$subject and $mail->addAddress , addAddress case is like this. Here is an example with greek text that's working without any text conversion:

EDIT

I've tested this code above and it's working:

$email = 'some@email.com';
$message =  'Όνομα: <br/>'.
    'eMail: <br/>'.
    'Τηλέφωνο: <br/>'.
    '(Ç, ç, äöüßÄÖÜ sollte hier gehen, açores)';

use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

$mail = new PHPMailer(true);

try {
    $mail->isMail();
    $mail->addAddress($email);
    $mail->setFrom('test@email.com', 'Mailer');
    $mail->CharSet = PHPMailer::CHARSET_UTF8;
    $mail->Subject = "[ΣΥΜΜΕΤΟΧΗ] Νέα φόρμα δήλωσης συμμετοχής (Ç, ç, äöüßÄÖÜ sollte hier gehen, açores)";

    $mail->msgHTML($message);
    $mail->send();
    echo 'Message has been sent';
} catch(Exception $e) {
    echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}

And here is the screenshot of the received email:

结果电子邮件屏幕截图

暂无
暂无

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

Related Question PHP Mail header for emails with special characters in the subject or message can I send special characters via $_POST? Send emails with international accent and special characters How I can send HTML emails with attachments? How can I send special characters as value in a ajax and decoded on php side? How can I export CSV with special characters? How can I allow special characters for a username? How can I send emails from a Symfony2 service class? how can I use PHPMailer to send emails with themosis/wordpress framework? How can I have an array of emails and make sure they all send?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM