Problems with phpmailer to add a php page

I have just started to try phpmailer, since I want to send a lot of e-mails to members.
The page is at hostmonster and not sure what is best to use.
Someone told me that smtp e-mails are the best, especially to get through to all sorts of users (Gmail, hotmail and so on).

I am using a cron job to send like 20 e-mails in a loop and then wait for a while before starting again.

I have a newsletter in a php page with old school tables to work as e-mail newsletter.
But every user have a unique link inside the e-mail for different things and unsubscribe and so on.
So, my link is something like:

In phpmailer I tried to add my link to the e-mail (yes I am a beginner here) and I couldn’t make it work.
When I run the debugger, it tells me the body message is empty.

This is parts of what I have:

$message = file_get_contents(''.$links.'');

Can anyone tell me what might be wrong in this code? Or how to add an URL like this that is local.

Or… isn’t phpmailer the thing I should use at all?

Could you please post the rest of your code as it’s hard to get a clear idea of what’s happening before and after your code snippet.

Have you tried echoing $message and see what it contains?

I had a problem on one website and the hosts recommended using SMTP for the emails. It fixed my problem of some form submissions being sent and others not. They said emails can be sent from a website but some emails can then be treated as spam as there is something missing in the headers. That can cause the website to be blacklisted - not sure about that - but the preferred method is SMTP through a mail server.

There are companies that you can use to send your emails and one I was looking at when I had the problem would send 1,2000 ( from memory ) emails a month for free and the price after that was not to bad. May be something to look into? I can not remember the company name now but if you are interested I will see if I can find it later.

Oops, I think I solved it. First there were two ‘’ at the end of the first line and the I discovered that $links was connected to an old query…
Now I just have some error codes to solve…

SMTP -> FROM ESMTP Exim 4.80 #2 Thu, 26 Sep 2013 04:08:44 -0600 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.

Any ideas?

I see a few things wrong with your code, first off, why are you using file_get_contents to embed a link in an email? Or did you really want to embed the HTML output for + the value of $links in your email?

Second, why are you calling file_get_contents twice! I think your second line should be $mail->MsgHTML($message);

Lastly, what is the value of $links? Is it id=1234 or just 1234? If it is just 1234, you need to add id= after your “newsletter.php?”

In other words, hostmonster feels you are spamming people and won’t permit you to send that many emails out.

@cpradio ;: I want to send the output of the URL, since it includes some unique links for the members. And I figured out that I was using that one twice. That part is working now. And the link is set to ?id=1234. I just forgot to enter that here.

But, it’s strange that hostmonster thinks I’m spamming, since my test e-mail only includes two members. There must be something else that is wrong?

I’m starting to wonder if that is an actual error message.

220 seems to be an informational message.

Check your username/password, the port you are sending on (may need to use 587, or a specific one), etc.

Oh another thought. What From address are you using? I know some hosts require you to send from your domain (otherwise, it is not permitted).

Thanks. I will check with hostmonster.

That’d probably be a good place to start, if they leave you with more questions than answers, feel free to update this thread and maybe we can help you implement/translate their response :slight_smile: