Clément Andraud
Clément Andraud

Reputation: 9279

Send mail works with command linux but not with PHP

I have many emails, gmail and other and I try to send an email to each. Actually, only 1 email receive the message, the other, gmail for example, doesn't.

With linux : The command echo "Hi" | mail -s "test" [email protected] works fine.

But with PHP, the mail do not go....

I have no error in my mail.log. Have you any ideas ?

Thanks !

Edit : I'am on a linux server.

Upvotes: 2

Views: 504

Answers (1)

ZanattMan
ZanattMan

Reputation: 736

Try something like this:

$mail = new PHPMailer(); // defaults to using php "mail()"
$body = $mailBody;
$mail->SetFrom('[email protected]'); 
$mail->AddAddress('[email protected]', 'Your Name');

$mail->Subject = 'The subject';
$mail->MsgHTML('The body');
$mail->Send();

Upvotes: 1

Related Questions