How to send Email from PHP with SMTP

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 64
Joined: Thu Mar 14, 2013 6:10 am

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


$Name = "dd"; //senders name
$email = ""; //senders e-mail adress
$recipient = ""; //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', ''); //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

php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

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;

Post Reply