简体   繁体   English

“SMTP连接()失败”。 配置它以从远程主机发送电子邮件时

[英]“SMTP connect() failed”. When configuring it to send emails from remote Host

I am new at PHP. 我是PHP新手。 I am using PHPMailer to send emails but unable to do so. 我使用PHPMailer发送电子邮件但无法这样做。 I tried configuring it for gmail and it worked But not working when tried to send msg from remote host and for the given domain. 我尝试为gmail配置它并且它工作但是当试图从远程主机和给定域发送消息时不工作。 Here is the code. 这是代码。

<?php  

       require("PHPMailerAutoload.php"); // path to the PHPMailerAutoload.php file.

       $mail = new PHPMailer();
       //$mail->IsSMTP();
       $mail->Mailer = "smtp";
       $mail->Host = "175.000.000.000"; //Sample Host
       $mail->SMTPDebug = 1;
       $mail->Port = "25"; // 8025, 587 and 25 can also be used. Use Port 465 for SSL.
       $mail->SMTPAuth = true;
       //$mail->SMTPSecure = 'ssl';
       $mail->Username = "maaz@mcbah.com";
       $mail->Password = "password";

       $mail->From     = "maaz@mcbah.com";
       $mail->FromName = "Maaz Khan";
       $mail->AddAddress("mcbah.all@mcbah.com", "all");
       $mail->AddReplyTo("fundprices@mcbah.com", "Fund");

       $mail->Subject  = "Hi!";
       $mail->Body     = "Hi! How are you?";
       $mail->WordWrap = 50;  

       if(!$mail->Send()) {
            echo 'Message was not sent.';
            echo 'Mailer error: ' . $mail->ErrorInfo;
                    echo 'Not sent: <pre>'.print_r(error_get_last(), true).'</pre>';
            exit;
       } else {
            echo 'Message has been sent.';
       }

This code may help you 此代码可能对您有所帮助

$mail->Host = "smtpout.secureserver.net"; $ mail-> Host =“smtpout.secureserver.net”;

Your host name should be like mydomain.com

$mail->Port = 465; $ mail-> Port = 465;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 SMTP 错误:无法连接到服务器:尝试使用 PhpMailer 发送电子邮件时没有到主机的路由 (65)? - Why SMTP ERROR: Failed to connect to server: No route to host (65) when trying to send email with PhpMailer? 无法连接到 SMTP 主机 - 无法验证证书 - Could not connect to SMTP host - failed to verify certificate laravel 从多个 smtp 电子邮件发送邮件 - laravel send mail from multiple smtp emails 我一直在尝试使用PHPMailer从本地主机发送电子邮件,但我无法修复此错误Mailer错误:SMTP connect()失败 - I have been trying to send email from my local host using PHPMailer but i cant fix this error Mailer Error: SMTP connect() failed SMTP-&gt;错误:无法连接到服务器:连接超时(110)SMTP错误:无法连接到SMTP主机。 - SMTP -> ERROR: Failed to connect to server: Connection timed out (110) SMTP Error: Could not connect to SMTP host. 即时消息使用hotmail地址发送成功的电子邮件,但使用gmail即时消息:SMTP错误:无法连接到SMTP主机 - Im sending emails with sucess using a hotmail adress, but with gmail Im getting: SMTP Error: Could not connect to SMTP host 如何从本地主机发送电子邮件? - How to send emails from local host? 从SMTP远程服务器CakePHP 3发送电子邮件 - Send Email from SMTP remote server CakePHP 3 使用SMTP时“无法连接到邮件服务器” - “Failed to connect to mailserver” when using SMTP 无法连接到 SMTP 主机 - Could not connect to SMTP host
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM