0

Hi guys ive got a problem with my mail() function.

if(mail('$email', 'test', 'test message'))
{
  echo('ok');
}
else
{
echo('not ok');
}

im trying to test this out.
ive tried manually inputting the email e.g. 12345@hotmail.com
the email is sent and i can receive it.
However, when i replace it with $email, the email is not sent.
when i echo $email it does show 12345@hotmail.com

what am i doing wrong?

Thanks
Danny

2
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by BigDan531
0

You cannot use a variable in a single quoted string. Use:

mail($email, 'test', 'test message')

or

mail("$email", 'test', 'test message')
0

hey thx man that solved my problem!

btw is there a code to add attachments? e.g image files?

0

Technically yes. You could MIME encode the attachments (see php.net for details). However, if you use a mail package (PEAR, PHPMailer, etc.) it will be much easier.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.