普通网友 2016-07-11 07:37
浏览 44

邮件功能和smtp在窗口服务器2008上不起作用

I'm trying to send email via mail() function and smtp but it does not work on windows server 2008, I checked same process and code on bluehost server which is working fine.

Mail Function Error

$headers  = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "
";
$headers .= 'To: Alen <example1@gmail.com>' . "
";
$headers .= 'From: john Smith <example2@gmail.com>' . "
";
$message = "
<strong>Hi xyz,  </strong><br />
<p>Your new password is asd,  </p>
";
echo mail('example1@gmail.com', 'Need to CHeck', $message, $headers);

I tried above email function which is giving me following error in error log.

PHP Warning: mail(): Failed to connect to mailserver at "mail.reliedhosting.com" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in

I tried this answer for resolving my issue but did not resolved.

SMTP Does not Connect

I also tried to connect smtp but it does not connecting.

require 'PHPMailerAutoload.php';
        $mail = new PHPMailer;
        $mail->isSMTP();
        $mail->SMTPDebug = 2;
        $mail->Debugoutput = 'html';
        $mail->Host = "mail.exampleDomain.com";
        $mail->Port = 25;
        $mail->SMTPAuth = true;
        $mail->Username = "info@cms.exampleDomain.ae";
        $mail->Password = "myPassWord";
        $mail->setFrom('info@cms.exampleDomain.ae', 'John');
        $mail->addReplyTo('web@example.com', 'Jimm');
        $mail->addAddress($email, $name);
        $mail->Subject = $subject;
        $mail->msgHTML('<h1>'.$message.'</h1>');
        $mail->AltBody = 'This is a plain-text message body';
        if (!$mail->send()) {
            echo "Mailer Error: " . $mail->ErrorInfo;
        } else {
            echo "Message sent!";
        }

Code is returning following error

SMTP ERROR: Failed to connect to server: The requested address is not valid in its context. (10049) SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting Mailer Error: SMTP connect() failed. https://github.com/PHPMailer/PHPMailer/wiki/TroubleshootingFunction Executed

I have searched for that, according to my research i thought that may be smtp cofiguration is not correct, but when i checked through phpinfo() it showing correct according to this reference.

I'm also attaching a part of phpinfo page, kindly view it. Can any one guide me where is the issue and how can i fix it I would like to highly appreciate. enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动