导出日历和发送邮件Outlook PHP

I get an Error: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp64\www\stage\views\mailtest.php on line 125

I didn't know how to modified the port. I had another code for sending and recieve mails and it's worked but now i need to create an event Calendar with sending mail.

function sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location)
{
    $domain = 'hotmail.com';

    //Create Email Headers
    $mime_boundary = "----Meeting Booking----".MD5(TIME());

    $headers = "From: ".$from_name." <".$from_address.">
";
    $headers .= "Reply-To: ".$from_name." <".$from_address.">
";
    $headers .= "MIME-Version: 1.0
";
    $headers .= "Content-Type: multipart/alternative; boundary=\"$mime_boundary\"
";
    $headers .= "Content-class: urn:content-classes:calendarmessage
";

    //Create Email Body (HTML)
    $message = "--$mime_boundary
";
    $message .= "Content-Type: text/html; charset=UTF-8
";
    $message .= "Content-Transfer-Encoding: 8bit

";
    $message .= "<html>
";
    $message .= "<body>
";
    $message .= '<p>Dear '.$to_name.',</p>';
    $message .= '<p>'.$description.'</p>';
    $message .= "</body>
";
    $message .= "</html>
";
    $message .= "--$mime_boundary
";

    $ical = 'BEGIN:VCALENDAR' . "
" .
        'PRODID:-//Microsoft Corporation//Outlook 10.0 MIMEDIR//EN' . "
" .
        'VERSION:2.0' . "
" .
        'METHOD:REQUEST' . "
" .
        'BEGIN:VTIMEZONE' . "
" .
        'TZID:Eastern Time' . "
" .
        'BEGIN:STANDARD' . "
" .
        'DTSTART:20091101T020000' . "
" .
        'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=1SU;BYMONTH=11' . "
" .
        'TZOFFSETFROM:-0400' . "
" .
        'TZOFFSETTO:-0500' . "
" .
        'TZNAME:EST' . "
" .
        'END:STANDARD' . "
" .
        'BEGIN:DAYLIGHT' . "
" .
        'DTSTART:20090301T020000' . "
" .
        'RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=2SU;BYMONTH=3' . "
" .
        'TZOFFSETFROM:-0500' . "
" .
        'TZOFFSETTO:-0400' . "
" .
        'TZNAME:EDST' . "
" .
        'END:DAYLIGHT' . "
" .
        'END:VTIMEZONE' . "
" .
        'BEGIN:VEVENT' . "
" .
        'ORGANIZER;CN="'.$from_name.'":MAILTO:'.$from_address. "
" .
        'ATTENDEE;CN="'.$to_name.'";ROLE=REQ-PARTICIPANT;RSVP=TRUE:MAILTO:'.$to_address. "
" .
        'LAST-MODIFIED:' . date("Ymd\TGis") . "
" .
        'UID:'.date("Ymd\TGis", strtotime($startTime)).rand()."@".$domain."
" .
        'DTSTAMP:'.date("Ymd\TGis"). "
" .
        'DTSTART;TZID="Eastern Time":'.date("Ymd\THis", strtotime($startTime)). "
" .
        'DTEND;TZID="Eastern Time":'.date("Ymd\THis", strtotime($endTime)). "
" .
        'TRANSP:OPAQUE'. "
" .
        'SEQUENCE:1'. "
" .
        'SUMMARY:' . $subject . "
" .
        'LOCATION:' . $location . "
" .
        'CLASS:PUBLIC'. "
" .
        'PRIORITY:5'. "
" .
        'BEGIN:VALARM' . "
" .
        'TRIGGER:-PT15M' . "
" .
        'ACTION:DISPLAY' . "
" .
        'DESCRIPTION:Reminder' . "
" .
        'END:VALARM' . "
" .
        'END:VEVENT'. "
" .
        'END:VCALENDAR'. "
";
    $message .= 'Content-Type: text/calendar;name="meeting.ics";method=REQUEST'."
";
    $message .= "Content-Transfer-Encoding: 8bit

";
    $message .= $ical;

    $mailsent = mail($to_address, $subject, $message, $headers);

    return ($mailsent)?(true):(false);
}
$from_name = "Omar Krichene";
$from_address = "krichene30@hotmail.com";
$to_name = "Omar Krichene";
$to_address = "krichen30@gmail.com";
$startTime = "11/07/2018 18:00:00";
$endTime = "11/07/2018 19:00:00";
$subject = "My Test Subject";
$description = "My Awesome Description";
$location = "Krichene House";
sendIcalEvent($from_name, $from_address, $to_name, $to_address, $startTime, $endTime, $subject, $description, $location);

1个回答



脚本无法连接到SMTP服务器。
您是否检查过本地主机或计算机上是否正在运行SMTP服务器 脚本是从端口25运行的吗?
如果您不需要提供有效的SMTP服务器地址并登录它。</ p>
</ div>

展开原文

原文

The script is not able to connect to the SMTP server. Have you checked if an SMTP server is running on the localhost or the computer the script is running from at port 25? If not you'll need to provide a working SMTP server address and login to it.

duanhaodi4809
duanhaodi4809 尝试telnetting:telnet localhost 25。 如果该命令产生否定结果,则系统或脚本配置中的某些内容已更改
大约 2 年之前 回复
dongwubao4785
dongwubao4785 我怎么检查它? (我发送这样的电子邮件,它的工作原理,我不认为那是关于那个)
大约 2 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐