DeanWhitehouse Posted June 18, 2008 Share Posted June 18, 2008 I have a email script, but there is a problem, PHP mail doesn't seem to want to work on the host, but SMTP does, as i have two CMS using it on my account. How can i set up my mail using SMTP?? This is my current mail code $to = htmlspecialchars($_POST['to']); $subject = htmlspecialchars($_POST['subject']); $from = htmlspecialchars($_POST['from']); $message = htmlspecialchars($_POST['message']); $header = "MIME-Version: 1.0\n"; $header .= "Content-type: text/plain; charset=iso-8859-1\n"; $header .= "From: $from <$from>\n"; $header .= "X-Mailer: PHP's mail() Function\n"; mail($to,$subject,$message,$header); Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/ Share on other sites More sharing options...
hitman6003 Posted June 18, 2008 Share Posted June 18, 2008 http://framework.zend.com/manual/en/zend.mail.html or http://phpmailer.codeworxtech.com/ Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-567710 Share on other sites More sharing options...
DeanWhitehouse Posted June 18, 2008 Author Share Posted June 18, 2008 After speaking to my host, i have resolved the problem in a sense. $fr = "my site email"; $to = htmlspecialchars($_POST['to']); $subject = htmlspecialchars($_POST['subject']); $from = htmlspecialchars($_POST['from']); $message = htmlspecialchars($_POST['message']); mail($to,$subject,$message,$header); $header = "MIME-Version: 1.0\n"; $header .= "Content-type: text/plain; charset=iso-8859-1\n"; $header .= "From: $fr <$fr>\n"; $header .= "X-Mailer: PHP's mail() Function\n"; $header .= "Reply-To: $from"; the problems i am having are: The email is being classed as a suspicous mail. Any ideas how to stop this. Also the bit in the email where it says who it is from is my site email, how can i get it to show there email ($from) but still send from mine? Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-568346 Share on other sites More sharing options...
trq Posted June 18, 2008 Share Posted June 18, 2008 The email is being classed as a suspicous mail. Any ideas how to stop this. Also the bit in the email where it says who it is from is my site email, how can i get it to show there email ($from) but still send from mine? The email will always be regarded as suspicious if the 'from' header does not match the hostname of the smtp sending the email. Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-568365 Share on other sites More sharing options...
DeanWhitehouse Posted June 18, 2008 Author Share Posted June 18, 2008 Ok, if i use SMTP will i be able to get it to not consider it ? Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-568369 Share on other sites More sharing options...
trq Posted June 18, 2008 Share Posted June 18, 2008 All email is sent via smtp so I'm not exactly sure where your going with your question. Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-568572 Share on other sites More sharing options...
DeanWhitehouse Posted June 19, 2008 Author Share Posted June 19, 2008 Well i need to know how to get it to send from my email, but appear like it is being sent through the persons email. Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-568890 Share on other sites More sharing options...
hitman6003 Posted June 19, 2008 Share Posted June 19, 2008 Well i need to know how to get it to send from my email, but appear like it is being sent through the persons email. Isn't that the definition of spam? Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-569026 Share on other sites More sharing options...
DeanWhitehouse Posted June 19, 2008 Author Share Posted June 19, 2008 No, i have a CMS on one of my sites, e107, and for this i have entered my SMTP settings and i can send an email from any name and email address. But i don't no how to do this, i beilieve i need to use SMTP directly to send it. Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-569384 Share on other sites More sharing options...
trq Posted June 19, 2008 Share Posted June 19, 2008 smtp is the email proticol, not a program. If you send an email via your server (foo.com) with an address in the 'From' header that isn't from that server (bar.com) it will be suspect to any mail client. Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-569654 Share on other sites More sharing options...
DeanWhitehouse Posted June 20, 2008 Author Share Posted June 20, 2008 Yes, but i have read of ways to send an email , where you enter your SMTP details then send it . Something like this http://email.about.com/od/emailprogrammingtips/qt/et073006.htm . I want to do what my cms does, which is send an email from any email address using my smtp settings. Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-569722 Share on other sites More sharing options...
trq Posted June 20, 2008 Share Posted June 20, 2008 So whats wrong with the sample in the link you posted? Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-569724 Share on other sites More sharing options...
DeanWhitehouse Posted June 20, 2008 Author Share Posted June 20, 2008 erm, cus i don't think i have PEAR, so i would need a way round using it Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-569728 Share on other sites More sharing options...
DeanWhitehouse Posted June 20, 2008 Author Share Posted June 20, 2008 Ok, i followed that tutorial and get an error Fatal error: Undefined class name 'mail' in /home/www/djw-webdesign.awardspace.com/Mail App/mailapp.php on line 100 this is the part of the code it refers to $host = ""; //my details removed $username = ""; // my details removed $password = ""; //my details removed //first off check if they have posted if(isset($_POST['send'])) { $to = htmlspecialchars($_POST['to']); $subject = htmlspecialchars($_POST['subject']); $from = htmlspecialchars($_POST['from']); $message = htmlspecialchars($_POST['message']); $error = 0; if($error == 0) { $header = "MIME-Version: 1.0\n"; $header .= "Content-type: text/plain; charset=iso-8859-1\n"; $header .= "From: $from <$from>\n"; $header .= "X-Mailer: PHP's mail() Function\n"; $header .= "Reply-To: $from"; $smtp = Mail::factory('smtp', array ('host' => $host, 'auth' => true, 'username' => $username, 'password' => $password)); $mail = $smtp->send($to, $subject, $header, $message); if (PEAR::isError($mail)) { echo("<p>" . $mail->getMessage() . "</p>"); } else { echo("<p>Message successfully sent!</p>"); } } Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-570500 Share on other sites More sharing options...
DeanWhitehouse Posted June 22, 2008 Author Share Posted June 22, 2008 bump Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-571237 Share on other sites More sharing options...
Darklink Posted June 22, 2008 Share Posted June 22, 2008 If you send emails, make sure they aren't from a noreply address. Some inbox's don't accept them and chuck them straight in the spam. Quote Link to comment https://forums.phpfreaks.com/topic/110664-php-mail-not-working-smtp-help/#findComment-571239 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.