dongqian9567 2016-08-12 15:17
浏览 112

是否可以使用phpmailer中的gmails的smtp从yahoo的电子邮件地址发送电子邮件

<?php

require ("PHPMailer-master/PHPMailerAutoload.php");

$mail = new PHPMailer;

if(isset($_POST['submit']))
{
    $email_query = "select email1,email2 from tbl_contacts where id = '1'";
    $query_result = mysql_query($email_query);
    $value = mysql_fetch_array($query_result);
    $primary_email = $value['email1'];
    $CC = $value['email2']; 

    $name = $_POST['name'];
    $email = $_POST['email'];
    $subject = $_POST['subject'];
    $message = $_POST['message'];
    $mail->IsSendmail();                                      // Set mailer to use SMTP
    $mail->Host = "smtp.google.com";  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = $email;                 // SMTP username
    //$mail->Password = 'password';                           // SMTP password
    $mail->SMTPSecure = 'ssl';                            // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 465;                                    // TCP port to connect to

    $mail->setFrom($email, $name);
    //$mail->addAddress('joe@example.net', 'Joe User');     // Add a recipient
    $mail->addAddress($primary_email);               // Name is optional
    $mail->addReplyTo($email, '');
    $mail->addCC($CC);
    //$mail->addBCC('bcc@example.com');

    //$mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
    //$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
    $mail->isHTML(true);                                  // Set email format to HTML

    $mail->Subject = $subject;
    $mail->Body    = $message;
    $mail->AltBody = $message;

    if(!$mail->send()) {
        echo 'Message could not be sent.';
        echo 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        echo 'Message has been sent';
        redirect('/contact.php?message=Your+Message+Has+Been+Sent!', 'location');
    }
}
?>

I am using gmail's smtp and it works fine if I send an email with a gmail account but when I send an email with an yahoo account it displays a success message but the message does not get delivered. Is it possible to send email from yahoo's email using gmail' smtp? If yes, how can I do it? And if not, how can I solve the problem?

  • 写回答

1条回答 默认 最新

  • doujuanqi2909 2016-08-12 15:27
    关注

    In general,

    avoid declaring incorrect identity.

    This might be possible from technical aspect; however in 2016 most email systems tend to protect themself by using multip. techniques - like SPF, DKIM and DMARC and that is both for sending and evaluating received emails.

    If this is true for more and more email systems and ESP's it's not hard to imagine what ESP giants like Yahoo, GMAIL and others are doing to express their hate on incorrectly declared identities (mark as spam, reject at SMTP handshake level, silently discard...).


    In your case displaying success message only mean that your mail is received on MTA side for further processing, not anything about it's future.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题