Forum Moderators: coopster

Message Too Old, No Replies

Emailing from Outlook with PHP?

         

Dexie

8:22 pm on Jan 4, 2006 (gmt 0)

10+ Year Member



Has anyone here used phpmailer please?

I've downloaded phpmailer, and have read the readme file, and gone through all the other accompanying files, but where do you <b>actually start</b> please?

I use Outlook 2003 to send and receive emails.

Any help very much appreciated.

Dexie.

StupidScript

10:25 pm on Jan 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi, and welcome to the forums!

Outlook or whatever mail client you are using does not matter. PHP is managed and interpreted by the server.

Here's a little code to help get you started. The two phpmailer class files contain all of the code for connecting to and authenticating on the mail server. Use proper authentication credentials where indicated.

require("class.phpmailer.php");

require("class.smtp.php");

# SEND MAIL

$mail = new PHPMailer();

$mail->IsSMTP();

$mail->Host  = "mail.example.com";

$mail->SMTPAuth = true;

$mail->Username = [b]'userid'[/b];

$mail->Password = [b]'password'[/b];

$mail->SetLanguage("en","/usr/local/apache/phpmailer/language/");

$mail->From  = "sender@example.com";

$mail->FromName = "Sender";

$mail->AddAddress("receiver@example2.com","Receiver");

$mail->Subject = 'Info from Example.com';

$mail->Body  = $msg_string;

if(!$mail->Send()) {

print("Message was not sent <p>");

echo "Mailer Error: " . $mail->ErrorInfo;

exit;

}

In this example, the

$msg_string
variable has already been populated with the message to send.

I also used hard-coded email addresses (To and From), where I would normally use variables drawn from the form being sent.

Don't forget the official site when looking for help: [phpmailer.sourceforge.net...] . You may also enjoy the extended examples: [phpmailer.sourceforge.net...]

Dexie

7:36 am on Jan 5, 2006 (gmt 0)

10+ Year Member



Many thanks for the welcome and helpful input - you may be the one to save my sanity, I've been trying to solve this problem for about 18 months and almost gave up. I was trying to send clients emails that stood out from the rest, with professional styling, but because some of the email clients that the recipients used, didn't interpret the code properly, they would just receive a load of garbled code - does phpmailer solve this problem completely please?

I did look through the links you gave, and in fact over the last 2 months, Ive looked all over their site, but can't seem to find the answers I need.

As mentioned, what are the <b> actual</b> steps to sending an email using phpmailer please? Do you start off in Outlook 2003 and then go to new message? What are the very 1st few steps please?

dreamcatcher

8:16 am on Jan 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dexie, you seemed to be getting confused about PHP mailer. Its a mailing class for sending mail data via a website form. It has nothing to do with an e-mail client such as Outlook.

dc

Dexie

9:11 am on Jan 5, 2006 (gmt 0)

10+ Year Member



Many thanks dc, the confusion is cleared up.

Back to the drawing board ;-( If anyone knows of an equally helpful place to find the solution, please let me know. I would be very grateful.

StupidScript

5:45 pm on Jan 5, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dexie, your challenge is great.

It seems like you are looking for a solution to deliver formatted email to every mail client, regardless of how the individual user has set up their client.

This is probably not do-able, because when a person has told their client to only view messages in plain text, you're stumped right there.

Your best bet is to compose your message so that it looks perfect (to you) in HTML and looks really cool (to you) when the same message is viewed in plain text without any images or bold text or centering or any other formatting.

There's no easy solution for your problem.

Dexie

3:44 pm on Jan 6, 2006 (gmt 0)

10+ Year Member



<quote>It seems like you are looking for a solution to deliver formatted email to every mail client, regardless of how the individual user has set up their client.</quote>

Not quite, just looking to send out multipart mime emails, that, as the name suggests, comes in multipart, 1 part is for plain text and another part is html, if the recipients email client/web interface is set to read in plain text only, then that is how they will view it, but if they have it set to read in html, then they will read the formatted version.

The solution is already out there somewhere - a lot of venues on the web actually discuss it, but I've not come across anywhere, that does a simple step-by-step on it.

coopster

4:11 pm on Jan 6, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Always start with the manual ;-)

The PHP mail() [php.net] function page has a great tutorial link to an old zend article that is a great primer.

[zend.com...]

Dexie

4:44 pm on Jan 6, 2006 (gmt 0)

10+ Year Member



Many thanks for the link Coopster, you've provided quite a few solutions for me over the years, so perhaps you've done it again ;-)

I'll report back.

coopster

5:01 pm on Jan 6, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



You're welcome.
I never knew that tutorial was there until one day jatar_k referenced it in a thread
[webmasterworld.com...]
The tutorial is well-written and will be very enlightening.

Dexie

5:40 pm on Jan 6, 2006 (gmt 0)

10+ Year Member



In case anyone's interested, I came across a link yesterday on sending emails in this way:

Can anyone see any info on that page? ;-)

[edited by: jatar_k at 5:50 pm (utc) on Jan. 6, 2006]
[edit reason] no urls thanks [/edit]

Dexie

1:05 pm on Jan 7, 2006 (gmt 0)

10+ Year Member



I've gone thru all of the links suggetsed, incl the 3 on the other thread, but am still finding probs with doing this.

Do you just copy and paste the php code into *every* email?

Has anyone found *actual* examples of simple step by steps to doing this start to finish in outlook 2003 anywhere please?

Dexie

1:30 pm on Jan 17, 2006 (gmt 0)

10+ Year Member



Still trying to solve this, if anyone can lend a hand.

Dex

coopster

2:33 pm on Jan 17, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Dexie your problem is beginning to seem more like a

"How do I send email as HTML and plain text in Outlook?"
as opposed to
"How do I send email as HTML and plain text using PHP from the server?"

First, you need to clarify exactly what you are trying to do again for us. Although it seemed like you were originally looking for a PHP mailing solution it seems now as if we may have misunderstood you. If it is the latter you are looking for, a PHP mailing solution, then the answers and examples have already been posted here.

Dexie

2:58 pm on Jan 17, 2006 (gmt 0)

10+ Year Member



Many thanks for the input Coopster, I'm a little unsure on what the potential solutions are - I'm only just formulating the question ;-)

OK, I'm composing and sending emails in Outlook 2003, using the html function, to people who have requested the html emails, but at the recipients end they receive garbled html code - this is despite the fact that Outlook is supposed to send mime multipart emails that should be readable, whether or not the recipients email client/web interface is set to read in plain text or not!!

By Googling for the last few months, it can be seen that some people have solved the problem in Outlook, but fall short of saying how they actually did it!

Question is, has anyone here found a way to always send an html email from Outlook 2003 so that it will always be in a readable format at the other end?

Any help appreciated.

Dexie.

coopster

3:34 pm on Jan 17, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't know how to send both. I can tell you that you can indeed override individual contacts though. To make sure Outlook always sends emails in plain text to a certain contact perform the following steps:
  1. Go to 'Contacts' and open the person's contact information
  2. Double-click the contact's email address
  3. Under 'Internet Format:' you want to select 'Send Plain Text Only'
  4. Save and close

Dexie

3:50 pm on Jan 17, 2006 (gmt 0)

10+ Year Member



Thanks for sticking with this Coopster (are we the only ones in here?), but that's the easy bit - as mentioned, this is for sending html.

coopster

4:08 pm on Jan 17, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Outlook automatically creates a plain text version of any HTML message you send. You cannot, however, separately control what that plain text version looks like. This is according to a MS MVP in a Microsoft Outlook newsgroup message [groups.google.com].

henry0

4:18 pm on Jan 17, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This might need an extra step, however users like options!
for example I do not like getting HTML email from untrusted sources.
Could you load to your webserver the HTML email version
then send a plain text email
which reads on its very top
something like "Formated message" and that will be a link to your HTML message.

BTW
What is now the PHP problem or question? :)

Dexie

4:19 pm on Jan 17, 2006 (gmt 0)

10+ Year Member



Thanks for the link. Then somethings going wrong somewhere, it seems as though the mime isn't properly constructed in Outlook 2003, because if it was, the recipient would be able to read it without seeing any html code, irregardless of their settings, which isn't the case.