dongzanghua8422 2017-02-16 21:55
浏览 57

是否可以通过PHP以编程方式从电子邮件地址中查找邮件子域或URL?

After a user create account, I plan on displaying a link to lead user to the mail server of his email. For example : if user1 has user1@gmail.com, the link would point towards gmail.com or mail.google.com. if user2 has user2@yahoo.com the link would point towards mail.yahoo.com.

In PHP I can do

$domain = explode("@", 'user1@gmail.com')[1];
$domain2 = explode("@", 'user2@yahoo.com')[1];
$mailUrl = $domain; //will work
$mailUrl2 = $domain; //will not work
$mailUrl = 'mail.'.$domain; //will not work
$mailUrl2 = 'mail.'.$domain; // will work

So I cannot predict manually the submain structure. I was wondering if there is a PHP function or Laravel 4 package that returns me the proper subdomain for the email address like gmail.com, mail.google.com, mail.yahoo.com, hotmail.com, etc.

  • 写回答

1条回答 默认 最新

  • dongrunying7537 2017-02-16 22:15
    关注

    You can easily achieve this using the PHP function getmxrr.

    Here's a snippet:

    <?php
        // Where the mx records will be added 
        $records = [];
    
        // Calling, change gmail.com to whatever you need
        getmxrr('gmail.com', $records);
    
        // dump the array's contents
        var_dump($records);
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?