doyhq66282 2013-09-10 11:32
浏览 18

mail()函数在laravel 4中不起作用

I was testing out my mail configuration. First I did a normal mail() call in a separate .php file. That worked fine. Then I copied the exact same code inside a route callback in Laravel 4 and now it doesn't work. How is that possible?

This is the code that works:

$from_add = "name@your-web-site.com"; 

$to_add = "someone@gmail.com"; //<-- put your yahoo/gmail email address here

$subject = "Test Subject";
$message = "Test Message";

$headers = "From: $from_add 
";
$headers .= "Reply-To: $from_add 
";
$headers .= "Return-Path: $from_add
";
$headers .= "X-Mailer: PHP 
";


mail($to_add,$subject,$message,$headers);

The adresses don't matter because I am testing with Test Mail Server Tool

  • 写回答

2条回答 默认 最新

  • dregvw1801 2013-09-10 11:47
    关注

    When working with Laravel 4, it's always advisable to use the built-in Mail function.

    This has a couple of advantages I wouldn't want to miss:

    • You can easily test mail features by setting the pretend option to true
    • It will allow you to send HTML mails using Blade views
    • You can choose which way your mails should be sent depending on your server config (sendmail, phpMailer)
    • You can queue mails so they will be sent later when there's less server load
    • You can do stuff after mail delivery in a callback function

    If you still insist on using the php mail() function, set your driver in app/config/mail.php to "mail".

    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值