SRL Archive - Web Development

mail() help please


Dynamite

2012-10-03 15:24:36

Hi guys long time no speak!
I am having troubles with this line of code:
[PHP]mail("$Email", "Thank you for your Enquiry", "Dear "$FirstName"", "we have recieved your enquiry and one of our professional FSA Regulated advisors will be in contact very soon! Thank you", "From: Enquiries.We-Remortgage");
[/PHP]

Could someone tell me what I am doing wrong? no experience with PHP :/

Thank you

masterBB

2012-10-03 15:31:37

Don't put $email between " ", I will look into it. one min

[PHP]Mail("myEmail@hotmail.com", "my subject", "the message","");[/PHP]

or with vars

[PHP]$mailadr = 'myEmail@hotmail.com';
$subject = 'my subject';
$msg= 'the message';

mail($mailadr, $subject, $msg, "");[/PHP]

or with a header with vars

[PHP]$mailadr = 'myEmail@hotmail.com';
$subject = 'my subject';
$msg = 'the message';
$header = 'From: BillGates@microsoft.com';

mail($mailadr, $subject, $msg, $header);[/PHP]

ape

2012-10-03 20:42:03

Also make sure you concatenate strings properly with a period. Take a look at http://php.net/manual/en/language.operators.string.php if you need help.

Dgby714

2012-10-03 21:11:40

I'm pretty sure you need a smtp server running. At least for that method.

Actually, It seems you can specify a smtp server in php.ini, but it defaults to a localhost server.

Dynamite

2012-10-05 06:12:26

Hi guys, cheers for the replies, basically I am retrieving info from a form in this instance $Email.
I need to send to that email.
And in the body of the message say:
"Dear $FirstName blah blah blah"

Cheers