Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

How to send Email from PHP with SMTP

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

How to send Email from PHP with SMTP

Postby stephenrodrics » Tue Jul 02, 2013 4:38 am

I want to send email from my PHP program, I am using PHP Mail function to send mail, but mail is not going

below is my code

<?php

$Name = "dd"; //senders name
$email = "test@gmail.com"; //senders e-mail adress
$recipient = "sam@hotmail.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

ini_set('sendmail_from', 'me@gmail.com'); //Suggested by "Some Guy"

mail($recipient, $subject, $mail_body, $header); //mail command :)
?>

Can anyone help with as I am unable to trace the error also
stephenrodrics
New php-forum User
New php-forum User
 
Posts: 58
Joined: Thu Mar 14, 2013 6:10 am

Re: How to send Email from PHP with SMTP

Postby johnj » Wed Jul 10, 2013 12:43 am

you need to trap the error or know why it is not getting send. use something like this,
$error = error_get_last();
echo $error;
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: Google [Bot] and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.