Need help with sending mails with PHP

I don’t know how to send mail with PHP from my website.

I’ve tried many codes that I found on different websites, but they dont work.
I’ve used the simplest ones like:

$message = “Line 1
Line 2
Line 3”;
$message = wordwrap($message, 70, "
mail(‘’, ‘My Subject’, $message);
(this one doesnt make sense because i am not specifying which e-mail i am using)

Also I’ve tried codes similiar to this one:


$to = ‘’;
$subject = ‘Test email’;
$message = "Hello World!

This is my first mail.";
$headers = “From:
$mail_sent = @mail( $to, $subject, $message, $headers, ‘f-’ );
//if the message is sent successfully print “Mail sent”. Otherwise print “Mail failed”
echo $mail_sent ? “Mail sent” : “Mail failed”;

It would mean so much if someone helped me, thanks!

Hi Ceneciga
Welcome to IW forums.
I am assuming your an end user if you do not know how to create or debug php. Apologies if I am wrong.
To answer your first question, the php mail is been sent via the hosting platform, which is set by the server admin where no sent from email address is shown (this though, maybe blank or disabled)
You can google for mail forms, and most should work, but just be aware that some are not designed for production use, only quick testing, and you should be able to add the following for error reporting, which should help (just place this at top of your php file
ini_set(‘display_errors’, ‘On’);
Remember to remove it when finished.
Please see below for a simple mail form (Do not use in production (ie on your website) - it is not secure and could be abused - form created by Tim Sisson)
//if “email” variable is filled out, send email
if (isset($_REQUEST[‘email’])) {

//Email information
$admin_email = “”;
$email = $_REQUEST[‘email’];
$subject = $_REQUEST[‘subject’];
$comment = $_REQUEST[‘comment’];

//send email
mail($admin_email, “$subject”, $comment, “From:” . $email);

//Email response
echo “Thank you for contacting us!”;

//if “email” variable is not filled out, display the form
else {
<form method=“post”>
Email: <input name=“email” type=“text” /><br />
Subject: <input name=“subject” type=“text” /><br />
Message:<br />
<textarea name=“comment” rows=“15” cols=“40”></textarea><br />
<input type=“submit” value=“Submit” />

If your still having issues, you could try websites which generate your code to be used, as here for an example, but I do not endorse this website or its use, it is just one found by google.
I hope that helps a little
Many thanks

This is the first time I’ve worked with PHP, if were talking about website developing I’ve worked with JSP,
anyways the code that you sent me doesn’t work, I’ve tested many e-mail forms I’ve found, none work,
I am really annoyed by this, and have no idea how to fix it, I don’t think I am making any mistakes.

Every code says e-mail is sent successfully but I don’t recieve the e-mails.

Thank you for explaining the e-mail process, I’ve only used SMTP mailing before.

I’ve also done a test with a code that tells you if e-mail is sent, and it says that it’s sent successfully.

Do you have any idea what else it could be?

Thanks for taking your time to reply.

Hi ceneciga

What version if php are you using

What level if IW are you using or have access too ie admin, reseller or siteworx

What version of IW are you using

I’m sorry I thought you were an end user, you might have been better to explain your skill set first.

You can always use smtp sending in php if you prefer

I’m sorry the posted form did not work, I have not tested it, but if you have access to mail logs, what is shown for mail sending

I guess the email if sent maybe in a spam filter perhaps, but to help more, more information is needed.

One point, is the domain email on the same server or is it using a third party. If third party provider, have you told siteworx that the email is external, if not, please set email to external - siteworx, administration, mail settings - set email to disable.

This will let IW know to send external and not deliver internal

Many thanks