Jump to content

mail using php


DrTrans

Recommended Posts

basically emailing form responce: 

I have my ini_set above variable Message

[code ]
ini_set("sendmail_from", "[email protected]");

$message  = "Here are your results";

$mailsubject = "Online Request from website";
    $headers  = "From: Elitecarolinas.com<$mainemail>\r\n";
    $headers .= 'MIME-Version: 1.0' . "\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $who = "[email protected]";
    $sendmail = mail("[email protected]",$mailsubject,$message,$headers);
echo "Sent Mail"

 

Why would this not send mail?

Link to comment
https://forums.phpfreaks.com/topic/200797-mail-using-php/
Share on other sites

What happens if you set it like this?

mail("[email protected]",$mailsubject,$message,$headers);
  $sendmail = mail("[email protected]",$mailsubject,$message,$headers);
echo "Sent Mail";

If that fails also I would have a look at the server SMTP settings you have set up

 

I have this setup on a server and it works fine:

$to      = $address;

$subject = 'Mail From : '.$sitename;

$message = $body;

$headers = 'From: [email protected]' . "\r\n" .

    'Reply-To: [email protected]' . "\r\n" .

    'Content-type:text/html;charset=iso-8859-1' . "\r\n" .

    'MIME-Version: 1.0' . "\r\n" ;

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

/php]

Feel free to copy and change/butcher for your own uses - even if it's just to test.

Link to comment
https://forums.phpfreaks.com/topic/200797-mail-using-php/#findComment-1053630
Share on other sites

I've fought with this on more than a few occasions.  The issue is always with the server's configuration.

 

****I'm assuming Linux server here....no idea how to work it on a windows machine**********

 

open up a second terminal and 'tail -f /var/log/syslog' then run the script.  You should get some errors that point you in the right direction.

 

Are you attempting to use sendmail or postfix?  have you modified your php.ini file?  Are you behind a firewall that blocks stmp traffic?

 

I've had the most luck using postfix to relay the mail out.

Link to comment
https://forums.phpfreaks.com/topic/200797-mail-using-php/#findComment-1053654
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.