The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Sending a text based email in PHP
tudsy
post Dec 3 2020, 03:40 AM
Post #1


Advanced Member
****

Group: Members
Posts: 246
Joined: 30-September 14
Member No.: 21,611



Hi

I am having trouble sending email in PHP. I am testing to see whether I can send a confirmation email to the user.

Here is sample code on how to send email in PHP:




$to ="";
$subject = "";
$message="";
$headers=" ";

/* recipients */
$to = $email;





/* subject */
$subject = "Confirm your email to join the Ecovib2d family";

/* message */
$message = "Ecovib2d Confirmation:

You are receiving this email because you filled out a registration form on this website.

If you did not subscribe, you can simply delete this email. No further action is required.

To complete confirmation and add your subscription, please click on the following link:


https://ecovib2d.com.au/workfromhome/subscr...&t=$to

Thank you and hope you enjoy using Ecovib2d!
";

// To send HTML mail - you can set the Content-type header

$headers = "MIME-Version: 1.0\r\n";
$headers = $headers." Content-type: text/html charset=iso-8859-1\r\n";

// additional headers
$headers = $headers."From: ADRIAN at ECOVIB2D <ecovib2d@live.com>\r\n";


// and now mail it
mail($to, $subject, $message, $headers);


Any help will be helpful.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Dec 3 2020, 07:49 PM
Post #2


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



After a quick look, the only thing I see that's wrong is this line:
CODE
$headers = $headers." Content-type: text/html charset=iso-8859-1\r\n";

It should be:
CODE
$headers = $headers." Content-type: text/html; charset=iso-8859-1\r\n";

You might need this in your message also, make sure it is the 1st line of your message:
CODE
"Content-Transfer-Encoding: 7bit\r\n\r\n";

You should consider sending both plain text and HTML emails.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Dec 4 2020, 08:46 AM
Post #3


.
********

Group: WDG Moderators
Posts: 9,630
Joined: 10-August 06
Member No.: 7



Also the $email variable is never given a value.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 29th March 2024 - 01:13 AM