开发者

mail() in lampp doesn't work

I'm trting to send a simple mail script in PHP. It doesn't work and I have no error in mail log or error log.

Here's my开发者_如何学Python php.ini config

SMTP = relais.videotron.ca
smtp_port = 25
sendmail_from = xxxx@xxxx.com (Of cours it's my ISP email there :D)
sendmail_path = /usr/sbin/sendmail -i -t

and my simple mail() test

mail("xxxx@xxxx.com","test","test");

Nothing's work. What could it be?


The built-in PHP mail command doesn't allow you to authenticate to an SMTP server. Your ISP SMTP server requires authentication and so is refusing the connection.

The info provided by your ISP confirms this;

SMTP server is accessible from an external network by using clear text authentication using your code "VL" or alias for your mail Example: customer@videotron.ca

Your options are either use an SMTP server that allows anonymous connections or (as Eamorr says) use a mailer class.


I use SwiftMailer:

require_once('../lib/swiftMailer/lib/swift_required.php');
...
function sendEmail(){
  //Sendmail
  $transport = Swift_SendmailTransport::newInstance('/usr/sbin/sendmail -bs');

  //Create the Mailer using your created Transport
  $mailer = Swift_Mailer::newInstance($transport);

  $body="Dear $fname,\n\nYour job application was successful. \n\nYours,\n\nEamorr\n\n\n\n\n\n\n";


  //Create a message
  $message = Swift_Message::newInstance('Subject goes here')
    ->setFrom(array($email => "no-reply@yourdomain.com"))
    ->setTo(array($email => "$fname $lname"))
    ->setBody($body);

  //Send the message
  $result = $mailer->send($message);
}

You can send both plaintext and html email with ease.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜